Class: Fulfillment::Models::Collection

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/fulfillment/models/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item_type, items) ⇒ Collection

Returns a new instance of Collection.



11
12
13
14
15
16
# File 'lib/fulfillment/models/collection.rb', line 11

def initialize(item_type, items)
  @_items = items
  @items = Array.wrap(_items).map do |item|
    item_type.new(item)
  end
end

Instance Attribute Details

#_itemsObject (readonly)

Returns the value of attribute _items.



7
8
9
# File 'lib/fulfillment/models/collection.rb', line 7

def _items
  @_items
end

#itemsObject (readonly)

Returns the value of attribute items.



7
8
9
# File 'lib/fulfillment/models/collection.rb', line 7

def items
  @items
end

Instance Method Details

#[](value) ⇒ Object



18
19
20
# File 'lib/fulfillment/models/collection.rb', line 18

def [](value)
  items.force[value]
end