Class: Dunder::Dispacter

Inherits:
Object
  • Object
show all
Defined in:
lib/dunder.rb

Overview

There maybe a better way of doing this

Instance Method Summary collapse

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