Class: Representable::Decorator

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

Constant Summary

Constants included from Representable

VERSION

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Representable

included, #update_properties_from

Constructor Details

#initialize(represented) ⇒ Decorator

Returns a new instance of Decorator.



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

def initialize(represented)
  @represented = represented
end

Instance Attribute Details

#representedObject (readonly)

Returns the value of attribute represented.



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

def represented
  @represented
end

Class Method Details

.prepare(represented) ⇒ Object



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

def self.prepare(represented)
  new(represented)  # was: PrepareStrategy::Decorate.
end

Instance Method Details

#representable_binding_for(attr, format, options) ⇒ Object



15
16
17
18
19
# File 'lib/representable/decorator.rb', line 15

def representable_binding_for(attr, format, options)
  context = attr.options[:representer_exec] ? self : represented  # DISCUSS: should Decorator know this kinda stuff?

  format.build(attr, represented, options, context)
end