Class: Representable::Decorator

Inherits:
Object
  • Object
show all
Includes:
Representable
Defined in:
lib/representable/decorator.rb

Constant Summary collapse

Coercion =

TODO: deprecate for 1.7.

Representable::Coercion

Constants included from Representable

VERSION

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Representable

included

Constructor Details

#initialize(represented) ⇒ Decorator

Returns a new instance of Decorator.



19
20
21
# File 'lib/representable/decorator.rb', line 19

def initialize(represented)
  @represented = represented
end

Instance Attribute Details

#representedObject (readonly) Also known as: decorated

Returns the value of attribute represented.



3
4
5
# File 'lib/representable/decorator.rb', line 3

def represented
  @represented
end

Class Method Details

.inline_representer(base_module, name, options, &block) ⇒ Object

DISCUSS: separate module?



10
11
12
13
14
15
# File 'lib/representable/decorator.rb', line 10

def self.inline_representer(base_module, name, options, &block) # DISCUSS: separate module?
  Class.new(self) do
    include base_module
    instance_exec &block
  end
end

.prepare(represented) ⇒ Object



6
7
8
# File 'lib/representable/decorator.rb', line 6

def self.prepare(represented)
  new(represented)
end