Module: PassionView::ViewModel::List

Extended by:
ActiveSupport::Concern, Enumerable
Included in:
Card::Collection
Defined in:
lib/passion_view/view_model/list.rb

Overview

items: enumerable

Instance Method Summary collapse

Instance Method Details

#eachObject



12
13
14
15
16
17
18
# File 'lib/passion_view/view_model/list.rb', line 12

def each
  return enum_for(:each) unless block_given?

  items.each do |e|
    yield item_view_model(e)
  end
end

#initialize(items, options = {}) ⇒ Object



6
7
8
9
10
# File 'lib/passion_view/view_model/list.rb', line 6

def initialize(items, options = {})
  super
  @items = items
  @item_view_model_class = options[:item_view_model_class]
end

#item_view_model(item) ⇒ Object



20
21
22
# File 'lib/passion_view/view_model/list.rb', line 20

def item_view_model(item)
  item_view_model_class.new(item)
end