Class: CollectionPresenter

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

Instance Method Summary collapse

Constructor Details

#initialize(nodes) ⇒ CollectionPresenter

Returns a new instance of CollectionPresenter.



39
40
41
42
# File 'lib/presenter.rb', line 39

def initialize(nodes)
  @context = nodes
  @nodes = nodes.map{ |n| n.presenter }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *attrs, &block) ⇒ Object



44
45
46
47
# File 'lib/presenter.rb', line 44

def method_missing(method, *attrs, &block)
  return @nodes.__send__(method, *attrs, &block) if @nodes.respond_to?(method)
  @context.__send__(method, *attrs, &block)
end