Skip to content

Commit

Permalink
Don't inherit from Proxy::Build
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaclayton committed Feb 10, 2012
1 parent daec7e3 commit 9826658
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/factory_girl/proxy/create.rb
@@ -1,13 +1,29 @@
module FactoryGirl
class Proxy #:nodoc:
class Create < Build #:nodoc:
class Create < 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)
to_create[result_instance]
run_callbacks(:after_create, 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

0 comments on commit 9826658

Please sign in to comment.