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.



46
47
48
# File 'lib/representable/decorator.rb', line 46

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

.build_inline(base, features, name, options, &block) ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/representable/decorator.rb', line 51

def self.build_inline(base, features, name, options, &block)
  Class.new(base || default_inline_class).tap do |decorator|
    decorator.class_eval do # Ruby 1.8.7 wouldn't properly execute the block passed to Class.new!
      feature *features
      class_eval &block
    end
  end
end

.default_inline_classObject



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

def self.default_inline_class
  Representable::Decorator
end

.prepare(represented) ⇒ Object

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



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

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