Module: Pymn::ChainOfResponsibility::Factory::ClassMethods

Defined in:
lib/pymn/chain_of_responsibility/factory.rb

Instance Method Summary collapse

Instance Method Details

#responsibility(class_method, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pymn/chain_of_responsibility/factory.rb', line 12

def responsibility class_method, &block
  singleton_class = class << self; self; end

  unless singleton_class.method_defined?(class_method)
    raise ResponsibilityMethodUndefinedError.new(class_method)
  end

  singleton_class.instance_eval do
    define_method(:create_factory) do
      FactoryCommand.new(self, class_method, block) 
    end
  end
end