Class: Mobj::Forwarder

Inherits:
BasicObject
Defined in:
lib/mobj.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root = nil, &handler) ⇒ Forwarder

Returns a new instance of Forwarder.



10
# File 'lib/mobj.rb', line 10

def initialize(root = nil, &handler) @root, @handler = root, handler end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



11
# File 'lib/mobj.rb', line 11

def method_missing(name, *args, &block) handler.call(name, *args, &block) end

Instance Attribute Details

#handlerObject

Returns the value of attribute handler.



9
10
11
# File 'lib/mobj.rb', line 9

def handler
  @handler
end

#rootObject

Returns the value of attribute root.



9
10
11
# File 'lib/mobj.rb', line 9

def root
  @root
end

Instance Method Details

#inspectObject



13
# File 'lib/mobj.rb', line 13

def inspect() { class:self.class, root:root, handler:handler}.inspect end

#to_aryObject



12
# File 'lib/mobj.rb', line 12

def to_ary() [root, handler] end