Class: Representable::Decorator
- Inherits:
-
Object
- Object
- Representable::Decorator
- Includes:
- Representable
- Defined in:
- lib/representable/decorator.rb
Constant Summary collapse
- Coercion =
TODO: deprecate for 1.7.
Representable::Coercion
Constants included from Representable
Instance Attribute Summary collapse
-
#represented ⇒ Object
(also: #decorated)
readonly
Returns the value of attribute represented.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(represented) ⇒ Decorator
constructor
A new instance of Decorator.
Methods included from Representable
Constructor Details
#initialize(represented) ⇒ Decorator
Returns a new instance of Decorator.
26 27 28 |
# File 'lib/representable/decorator.rb', line 26 def initialize(represented) @represented = represented end |
Instance Attribute Details
#represented ⇒ Object (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
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/representable/decorator.rb', line 10 def self.inline_representer(base_module, name, , &block) # FIXME: it is wrong to inherit from self here as we just want to "inherit" the included modules but nothing else. Class.new(self).tap do |decorator| decorator.class_eval do # Ruby 1.8.7 wouldn't properly execute the block passed to Class.new! # Remove parent's property definitions before defining the inline ones. #FIXME: don't inherit from self, remove those 2 lines. representable_attrs.clear representable_attrs.inheritable_arrays.clear include *base_module instance_exec &block end end end |
.prepare(represented) ⇒ Object
6 7 8 |
# File 'lib/representable/decorator.rb', line 6 def self.prepare(represented) new(represented) end |