Class: Enrich::Base

Inherits:
Object
  • Object
show all
Includes:
AutoDelegate
Defined in:
lib/enrich/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AutoDelegate

#delegatable?, #method_missing, #respond_to_missing?

Constructor Details

#initialize(object) ⇒ Base

Returns a new instance of Base.



19
20
21
# File 'lib/enrich/base.rb', line 19

def initialize(object)
  @object = object
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Enrich::AutoDelegate

Class Method Details

.decorate(object) ⇒ Object Also known as: d



8
9
10
11
12
13
14
# File 'lib/enrich/base.rb', line 8

def decorate(object)
  if object.is_a?(ActiveRecord::Base)
    new(object)
  else
    object.map { |obj| new(obj) }
  end
end

Instance Method Details

#hObject

Ability to use ActionController helpers



28
29
30
# File 'lib/enrich/base.rb', line 28

def h
  ActionController::Base.helpers
end

#objectObject



23
24
25
# File 'lib/enrich/base.rb', line 23

def object
  @object
end