class PresenterObject::Collection

Presenter superclass for collections. Create your own collection presenter by sub-classing `PresenterObject::Collection`.

e.g:

class DocumentCollectionPresenter << PresenterObject::Collection
 .. add methods here ..
end

Create a presenter instance by giving it a model instance e.g:

documents = DocumentCollectionPresenter.new Document.where(publish: true) 
documents.method_that_presents_collection

Attributes

collection[R]
object[R]
view_context[R]

Public Class Methods

new(collection, view_context = nil) click to toggle source
# File lib/presenter_object/collection.rb, line 20
def initialize(collection, view_context = nil)
  @collection = collection
  @view_context = view_context
end

Public Instance Methods

each() { |presenterize view_context| ... } click to toggle source
# File lib/presenter_object/collection.rb, line 25
def each
  @collection.each { |object| yield object.presenterize view_context }
end