Class: PartialPathCustomizer::Presenter

Inherits:
DumbDelegator
  • Object
show all
Defined in:
lib/partial_path_customizer/presenter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, &partial_path_block) ⇒ Presenter

Returns a new instance of Presenter.



11
12
13
14
# File 'lib/partial_path_customizer/presenter.rb', line 11

def initialize(object, &partial_path_block)
  super(object)
  @partial_path_block = partial_path_block
end

Class Method Details

.wrap_collection(collection, &partial_path_block) ⇒ Object



5
6
7
8
9
# File 'lib/partial_path_customizer/presenter.rb', line 5

def self.wrap_collection collection, &partial_path_block
  collection.map do |obj|
    new obj, &partial_path_block
  end
end

Instance Method Details

#to_modelObject



24
25
26
# File 'lib/partial_path_customizer/presenter.rb', line 24

def to_model
  self
end

#to_partial_pathObject



16
17
18
19
20
21
22
# File 'lib/partial_path_customizer/presenter.rb', line 16

def to_partial_path
  if @partial_path_block.present?
    @partial_path_block.call(_model)
  else
    __getobj__.to_partial_path
  end
end