Class: Dunder::Dispacter
- Inherits:
-
Object
- Object
- Dunder::Dispacter
- Defined in:
- lib/dunder.rb
Overview
There maybe a better way of doing this
Instance Method Summary collapse
-
#initialize(object, group = nil) ⇒ Dispacter
constructor
A new instance of Dispacter.
- #method_missing(method_sym, *arguments, &block) ⇒ Object
Constructor Details
#initialize(object, group = nil) ⇒ Dispacter
Returns a new instance of Dispacter.
129 130 131 132 |
# File 'lib/dunder.rb', line 129 def initialize(object,group = nil) @_dunder_group = group @_dunder_obj = object end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
134 135 136 137 138 139 |
# File 'lib/dunder.rb', line 134 def method_missing(method_sym, *arguments,&block) disp = @_dunder_group ? @_dunder_group : DunderMethod disp.lazy_load do @_dunder_obj.send(method_sym, *arguments,&block) end end |