Module: Findr::StrategyProxy::ClassMethods
- Defined in:
- lib/findr/strategy_proxy.rb
Instance Method Summary collapse
- #provides(method_name, *argument_names) ⇒ Object
-
#singleton_provides(method_name, *argument_names) ⇒ Object
before using
singleton_providesyou must define @@strategy BEFORE FIRST USE of the defined singleton methods.
Instance Method Details
#provides(method_name, *argument_names) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/findr/strategy_proxy.rb', line 26 def provides(method_name, *argument_names) arglist = argument_names.map(&:to_sym).join(',') method_string = " def \#{method_name}(\#{arglist})\n @strategy.\#{method_name}(\#{arglist})\n rescue NoMethodError\n does_not_implement_method(@strategy, '\#{method_name}')\n end\n END_METHOD\n class_eval method_string\nend\n" |
#singleton_provides(method_name, *argument_names) ⇒ Object
before using singleton_provides you must define @@strategy BEFORE FIRST USE of the defined singleton methods
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/findr/strategy_proxy.rb', line 39 def singleton_provides(method_name, *argument_names) arglist = argument_names.map(&:to_sym).join(',') method_string = " def self.\#{method_name}(\#{arglist})\n @@strategy.\#{method_name}(\#{arglist})\n rescue NoMethodError\n does_not_implement_method(@@strategy, 'self.\#{method_name}')\n end\n END_METHOD\n class_eval method_string\nend\n" |