Class: Loverload::Method
- Inherits:
-
Object
- Object
- Loverload::Method
- Defined in:
- lib/loverload/method.rb
Instance Method Summary collapse
-
#initialize(klass, method_name, &with_params_block) ⇒ Method
constructor
A new instance of Method.
- #overload(instance, *args, &block) ⇒ Object
- #with_params(*pars, &block) ⇒ Object
Constructor Details
#initialize(klass, method_name, &with_params_block) ⇒ Method
Returns a new instance of Method.
3 4 5 6 7 8 9 |
# File 'lib/loverload/method.rb', line 3 def initialize klass, method_name, &with_params_block @klass, @method_name = klass, method_name dictionary || @klass.instance_variable_set(:@__dictionary__, {}) instance_eval(&with_params_block) end |
Instance Method Details
#overload(instance, *args, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/loverload/method.rb', line 17 def overload instance, *args, &block if block_given? args << Block.new(&block) found = find(*args) instance.instance_exec *args do |*args| found.call(*args, &(args.pop.block)) end else instance.instance_exec *args, &find(*args) end end |