Class: ClassicPresenter::Base
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ClassicPresenter::Base
- Defined in:
- lib/classic_presenter/base.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(model, context = nil, objects = {}) ⇒ Base
constructor
A new instance of Base.
- #target ⇒ Object
Constructor Details
#initialize(model, context = nil, objects = {}) ⇒ Base
Returns a new instance of Base.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/classic_presenter/base.rb', line 5 def initialize(model, context = nil, objects = {}) objects.each do |key, value| self.class.send :define_method, key do value end end @context = context super model end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
3 4 5 |
# File 'lib/classic_presenter/base.rb', line 3 def context @context end |
Class Method Details
.map(collection, context = nil) ⇒ Object
20 21 22 |
# File 'lib/classic_presenter/base.rb', line 20 def self.map(collection, context = nil) collection.map {|item| self.new(item, context)} end |
Instance Method Details
#target ⇒ Object
16 17 18 |
# File 'lib/classic_presenter/base.rb', line 16 def target self.__getobj__ end |