Class: Adorn::ObjectDecorator

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

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ SimpleDelegator



6
7
8
# File 'lib/adorn/object_decorator.rb', line 6

def initialize(object)
  @object = SimpleDelegator.new(object)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



10
11
12
13
14
# File 'lib/adorn/object_decorator.rb', line 10

def method_missing(method, *args, &block)
  @object.send(method, *args, &block)
rescue => e
  super(method, *args, &block)
end

Instance Method Details

#respond_to_missing?(method) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/adorn/object_decorator.rb', line 16

def respond_to_missing?(method,*)
  method =~ /#{method.to_s}/ || super
end