Class: ClassicPresenter::Base

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/classic_presenter/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#contextObject

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

#targetObject



16
17
18
# File 'lib/classic_presenter/base.rb', line 16

def target
  self.__getobj__
end