Class: Light::Decorator::Decorate

Inherits:
Object
  • Object
show all
Defined in:
lib/light/decorator/decorate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, options = {}) ⇒ Object

Decorate the object

Parameters:

  • object (Object)

    for decoration

  • options (Hash) (defaults to: {})


13
14
15
16
17
18
19
# File 'lib/light/decorator/decorate.rb', line 13

def initialize(object, options = {})
  @object = object
  @options = options

  delegate_methods
  decorate_associations
end

Instance Attribute Details

#objectObject (readonly) Also known as: o

Returns original object.

Returns:

  • original object



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

def object
  @object
end

Instance Method Details

#==(other) ⇒ Object



36
37
38
# File 'lib/light/decorator/decorate.rb', line 36

def ==(other)
  super || object == other
end

#decorated?Bool

Check current ActiveRecord::Model is decorated or not

Returns:

  • (Bool)


24
25
26
# File 'lib/light/decorator/decorate.rb', line 24

def decorated?
  true
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/light/decorator/decorate.rb', line 40

def eql?(other)
  super || object.eql?(other)
end

#helpersActionView::Base Also known as: h

Current view scope

Returns:

  • (ActionView::Base)


31
32
33
34
# File 'lib/light/decorator/decorate.rb', line 31

def helpers
  return @helpers if defined?(@helpers)
  @helpers = Light::Decorator::ViewContext.current
end