Sha256: 991b2fff42fa448c548d8c75c1f9d2dc7c71befdeef0ffd5dd5579c1e8ec22e5

Contents?: true

Size: 977 Bytes

Versions: 20

Compression:

Stored size: 977 Bytes

Contents

module FactoryGirl
  class DefinitionHierarchy
    def callbacks
      FactoryGirl.callbacks
    end

    def constructor
      FactoryGirl.constructor
    end

    def to_create
      FactoryGirl.to_create
    end

    def self.build_from_definition(definition)
      build_to_create(&definition.to_create)
      build_constructor(&definition.constructor)
      add_callbacks definition.callbacks
    end

    def self.add_callbacks(callbacks)
      if callbacks.any?
        define_method :callbacks do
          super() + callbacks
        end
      end
    end
    private_class_method :add_callbacks

    def self.build_constructor(&block)
      if block
        define_method(:constructor) do
          block
        end
      end
    end
    private_class_method :build_constructor

    def self.build_to_create(&block)
      if block
        define_method(:to_create) do
          block
        end
      end
    end
    private_class_method :build_to_create
  end
end

Version data entries

20 entries across 17 versions & 8 rubygems

Version Path
ffactory_girl-4.8.2 lib/factory_girl/definition_hierarchy.rb
factory_girl-4.9.0 lib/factory_girl/definition_hierarchy.rb
ffactory_girl-4.8.1 lib/factory_girl/definition_hierarchy.rb
factory_girl-4.8.1 lib/factory_girl/definition_hierarchy.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/factory_girl-4.8.0/lib/factory_girl/definition_hierarchy.rb
factory_girl-4.8.0 lib/factory_girl/definition_hierarchy.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/factory_girl-4.7.0/lib/factory_girl/definition_hierarchy.rb
factory_girl-4.7.0 lib/factory_girl/definition_hierarchy.rb
opal-factory_girl-4.5.0.3 factory_girl/lib/factory_girl/definition_hierarchy.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/factory_girl-4.5.0/lib/factory_girl/definition_hierarchy.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/factory_girl-4.5.0/lib/factory_girl/definition_hierarchy.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/factory_girl-4.5.0/lib/factory_girl/definition_hierarchy.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/factory_girl-4.5.0/lib/factory_girl/definition_hierarchy.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/definition_hierarchy.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/factory_girl-4.4.0/lib/factory_girl/definition_hierarchy.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/factory_girl-4.4.0/lib/factory_girl/definition_hierarchy.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/definition_hierarchy.rb
factory_girl-4.5.0 lib/factory_girl/definition_hierarchy.rb
factory_girl-4.4.0 lib/factory_girl/definition_hierarchy.rb
factory_girl-4.3.0 lib/factory_girl/definition_hierarchy.rb