Permalink
Browse files

Use delegation from AS

  • Loading branch information...
1 parent 180eb8b commit 9e88eb10de723918582881e095f61c19300b846d @joshuaclayton joshuaclayton committed Oct 15, 2011
Showing with 4 additions and 13 deletions.
  1. +4 −13 lib/factory_girl/factory.rb
@@ -1,4 +1,5 @@
require "active_support/core_ext/hash/keys"
+require "active_support/core_ext/module/delegation"
require "active_support/inflector"
module FactoryGirl
@@ -18,6 +19,8 @@ def initialize(name, options = {}) #:nodoc:
@compiled = false
end
+ delegate :overridable?, :declarations, :declare_attribute, :to => :@attribute_list
+
def factory_name
$stderr.puts "DEPRECATION WARNING: factory.factory_name is deprecated; use factory.name instead."
name
@@ -37,10 +40,6 @@ def allow_overrides
self
end
- def allow_overrides?
- @attribute_list.overridable?
- end
-
def define_trait(trait)
@defined_traits << trait
end
@@ -132,10 +131,6 @@ def ensure_compiled
compile unless @compiled
end
- def declare_attribute(declaration)
- @attribute_list.declare_attribute(declaration)
- end
-
protected
def class_name #:nodoc:
@@ -174,11 +169,7 @@ def compile
def inherit_factory(parent) #:nodoc:
parent.ensure_compiled
- allow_overrides if parent.allow_overrides?
- end
-
- def declarations
- @attribute_list.declarations
+ allow_overrides if parent.overridable?
end
def define_attribute(attribute)

0 comments on commit 9e88eb1

Please sign in to comment.