Class: Enrich::Base
Class Method Summary collapse
- .decorate(object) ⇒ Object (also: d)
Instance Method Summary collapse
-
#h ⇒ Object
Ability to use ActionController helpers.
-
#initialize(object) ⇒ Base
constructor
A new instance of Base.
- #object ⇒ Object
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
#h ⇒ Object
Ability to use ActionController helpers
28 29 30 |
# File 'lib/enrich/base.rb', line 28 def h ActionController::Base.helpers end |
#object ⇒ Object
23 24 25 |
# File 'lib/enrich/base.rb', line 23 def object @object end |