lib/faker_maker/base.rb in faker_maker-1.1.3 vs lib/faker_maker/base.rb in faker_maker-1.1.4
- old
+ new
@@ -2,13 +2,18 @@
module FakerMaker
# Base module for defining the DSL
module Base
def factory(name, options = {}, &block)
- factory = FakerMaker::Factory.new name, options
- proxy = DefinitionProxy.new factory
- proxy.instance_eval( &block ) if block_given?
- FakerMaker.register_factory factory
+ factory = FakerMaker.find_factory(name)
+ if factory.nil?
+ factory = FakerMaker::Factory.new name, options
+ proxy = DefinitionProxy.new factory
+ proxy.instance_eval( &block ) if block_given?
+ FakerMaker.register_factory factory
+ else
+ factory
+ end
end
end
end