Module: Panier::Decorators::Decorator

Included in:
ReceiptDecorator
Defined in:
lib/panier/decorators/decorator.rb

Overview

Defines basic behaviour common to decorators.

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



15
16
17
18
# File 'lib/panier/decorators/decorator.rb', line 15

def method_missing(symbol, *args, &block)
  super unless @decorated.respond_to? symbol
  @decorated.send(symbol, *args, &block)
end

Instance Attribute Details

#decoratedObject (readonly)

Returns the value of attribute decorated.



9
10
11
# File 'lib/panier/decorators/decorator.rb', line 9

def decorated
  @decorated
end

Instance Method Details

#initialize(decorated) ⇒ Object



11
12
13
# File 'lib/panier/decorators/decorator.rb', line 11

def initialize(decorated)
  @decorated = decorated
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/panier/decorators/decorator.rb', line 20

def respond_to_missing?(name, include_private = false)
  @decorated.respond_to?(name, include_private) || super
end