1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/lib/factory_girl/proxy/build.rb

27 lines
649 B
Ruby
Raw Normal View History

module FactoryGirl
2009-01-02 16:39:24 -05:00
class Proxy #:nodoc:
2009-02-17 16:38:15 -05:00
class Build < Proxy #:nodoc:
2011-12-06 17:26:48 -05:00
def self.association(factory_name, overrides = {})
factory = FactoryGirl.factory_by_name(factory_name)
factory.run(get_method(overrides[:method]), overrides.except(:method))
end
2011-12-06 17:26:48 -05:00
def result
2009-10-10 00:46:19 -04:00
run_callbacks(:after_build)
result_instance
2008-12-23 14:03:29 -05:00
end
private
2011-12-06 17:26:48 -05:00
def self.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
2008-12-23 14:03:29 -05:00
end
end
end