Class: Representable::Decorator

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

Defined Under Namespace

Modules: InheritModule

Constant Summary

Constants included from Representable

VERSION

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from InheritModule

inherit_module!

Methods included from Representable

included

Constructor Details

#initialize(represented) ⇒ Decorator

Returns a new instance of Decorator.



54
55
56
# File 'lib/representable/decorator.rb', line 54

def initialize(represented)
  @represented = represented
end

Instance Attribute Details

#representedObject (readonly) Also known as: decorated

Returns the value of attribute represented.



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

def represented
  @represented
end

Class Method Details

.cloneObject

This is called from inheritable_attr when inheriting a decorator class to a subclass. Explicitly subclassing the Decorator makes sure representable_attrs is a clean version.



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

def self.clone
  Class.new(self) # DISCUSS: why isn't this called by Ruby?
end

.default_inline_classObject



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

def self.default_inline_class
  Representable::Decorator
end

.prepare(represented) ⇒ Object

TODO: when moving all class methods into ClassMethods, i get a segfault.



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

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