Class: BravoPresenter::Collection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/bravo_presenter/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection, template) ⇒ Collection

nodoc



9
10
11
12
# File 'lib/bravo_presenter/collection.rb', line 9

def initialize(collection, template)
  self.collection = collection
  self.template = template
end

Instance Attribute Details

#collectionObject

Returns the value of attribute collection.



3
4
5
# File 'lib/bravo_presenter/collection.rb', line 3

def collection
  @collection
end

#templateObject

Returns the value of attribute template.



3
4
5
# File 'lib/bravo_presenter/collection.rb', line 3

def template
  @template
end

Instance Method Details

#each(&block) ⇒ Object

nodoc



16
17
18
19
20
# File 'lib/bravo_presenter/collection.rb', line 16

def each(&block)
  collection.each do |obj|
    block.call template.present_object(obj)
  end
end

#empty?Boolean

nodoc



24
25
26
# File 'lib/bravo_presenter/collection.rb', line 24

def empty?
  count == 0
end