Class: InspectedBy::Decorator

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

Direct Known Subclasses

DiffDecorator, LineDecorator

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ Decorator

Returns a new instance of Decorator.



12
13
14
# File 'lib/inspected_by/core.rb', line 12

def initialize(object)
  @object = object
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



28
29
30
# File 'lib/inspected_by/core.rb', line 28

def method_missing(method, *args, &block)
  @object.send method, *args, &block
end

Class Method Details

.decorate(objects) ⇒ Object



20
21
22
# File 'lib/inspected_by/core.rb', line 20

def self.decorate(objects)
  objects.map(&method(:new))
end

.decorates(klass) ⇒ Object



16
17
18
# File 'lib/inspected_by/core.rb', line 16

def self.decorates(klass)
  define_method(klass) { @object }
end

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



24
25
26
# File 'lib/inspected_by/core.rb', line 24

def self.method_missing(method, *args, &block)
  @object.send method, *args, &block
end