Sha256: 291dbbc2c58e2e3939ad915606eebeb422c8b8e3ef821c1bf370e58facef32ee

Contents?: true

Size: 736 Bytes

Versions: 22

Compression:

Stored size: 736 Bytes

Contents

module FactoryGirl
  class Proxy #:nodoc:
    class Build < Proxy #:nodoc:
      def association(factory_name, overrides = {})
        factory = FactoryGirl.factory_by_name(factory_name)
        factory.run(get_method(overrides[:method]), overrides.except(:method))
      end

      def result(attribute_assigner, to_create)
        attribute_assigner.object.tap do |result_instance|
          run_callbacks(:after_build, result_instance)
        end
      end

      private

      def get_method(method)
        case method
        when :build  then Proxy::Build
        when :create then Proxy::Create
        when nil     then Proxy::Create
        else raise "unrecognized method #{method}"
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
challah-0.6.1 vendor/bundle/gems/factory_girl-2.5.1/lib/factory_girl/proxy/build.rb
challah-0.6.0 vendor/bundle/gems/factory_girl-2.5.1/lib/factory_girl/proxy/build.rb
challah-0.5.4 vendor/bundle/gems/factory_girl-2.5.1/lib/factory_girl/proxy/build.rb
challah-0.5.3 vendor/bundle/gems/factory_girl-2.5.1/lib/factory_girl/proxy/build.rb
challah-0.5.2 vendor/bundle/gems/factory_girl-2.5.1/lib/factory_girl/proxy/build.rb
challah-0.5.0 vendor/bundle/gems/factory_girl-2.5.1/lib/factory_girl/proxy/build.rb
factory_girl-2.5.2 lib/factory_girl/proxy/build.rb
challah-0.4.1 vendor/bundle/gems/factory_girl-2.5.1/lib/factory_girl/proxy/build.rb
challah-0.4.0 vendor/bundle/gems/factory_girl-2.5.1/lib/factory_girl/proxy/build.rb
challah-0.3.5 vendor/bundle/gems/factory_girl-2.5.1/lib/factory_girl/proxy/build.rb
challah-0.3.4 vendor/bundle/gems/factory_girl-2.5.1/lib/factory_girl/proxy/build.rb
challah-0.3.3 vendor/bundle/gems/factory_girl-2.5.1/lib/factory_girl/proxy/build.rb
challah-0.3.2 vendor/bundle/gems/factory_girl-2.5.1/lib/factory_girl/proxy/build.rb
challah-0.3.1 vendor/bundle/gems/factory_girl-2.5.1/lib/factory_girl/proxy/build.rb
factory_girl-2.5.1 lib/factory_girl/proxy/build.rb
challah-0.3.0 vendor/bundle/gems/factory_girl-2.5.0/lib/factory_girl/proxy/build.rb
challah-0.2.1 vendor/bundle/gems/factory_girl-2.5.0/lib/factory_girl/proxy/build.rb
challah-0.2.0 vendor/bundle/gems/factory_girl-2.5.0/lib/factory_girl/proxy/build.rb
factory_girl-2.5.0 lib/factory_girl/proxy/build.rb
factory_girl-2.4.2 lib/factory_girl/proxy/build.rb