Sha256: 6e063a8de9b28449440a3f403390f68b4042e8b7ad7e7df07f1f6e879654f3cd

Contents?: true

Size: 773 Bytes

Versions: 1

Compression:

Stored size: 773 Bytes

Contents

module FactoryGirl
  class Proxy #:nodoc:
    class Build < Proxy #:nodoc:
      def initialize(klass)
        @instance = klass.new
      end

      def get_attr(attribute)
        @instance.send(attribute)
      end

      def set_attr(attribute, value)
        @instance.send(:"#{attribute}=", value)
      end

      def associate(name, factory_name, overrides)
        factory = FactoryGirl.factory_by_name(factory_name)
        set(name, factory.run(Proxy::Create, overrides))
      end

      def association(factory_name, overrides = {})
        factory = FactoryGirl.factory_by_name(factory_name)
        factory.run(Proxy::Create, overrides)
      end

      def result(to_create)
        run_callbacks(:after_build)
        @instance
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
factory_girl_kibiz0r-2.0.0.beta3 lib/factory_girl/proxy/build.rb