lib/dokkit/factory/factory.rb in dokkit-0.4.4 vs lib/dokkit/factory/factory.rb in dokkit-0.5.0

- old
+ new

@@ -25,14 +25,14 @@ # Add a factory method associated with the given class of objects. # +factory_method+ is a class/method pair. # # Example: # - # factory.add(:bar => bar_factory_method) # add a method that - # # instantiates Bar object + # factory.add(:bar) { Bar.new } # add a method that + # # instantiates Bar object # - def add(factory_method) - @methods.merge! factory_method + def add(key, &factory_method) + @methods[key] = factory_method end # Construct an instance for the given class. Note that, if an # instance of the same class has been already instantiated for a # given parameters set, then *no* new instance will be created but