Sha256: f861f5a297c0bb3477ac5483c3dc760313cd8ef16616b126fa83d760fc50b12e

Contents?: true

Size: 435 Bytes

Versions: 2

Compression:

Stored size: 435 Bytes

Contents

module Fulfillment
  module Models
    class Collection
      include Enumerable
      extend Forwardable

      attr_reader :items, :_items

      delegate [:[], :each, :last, :size] => :items

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fulfillment-api-1.1.9 lib/fulfillment/models/collection.rb
fulfillment-api-1.1.7 lib/fulfillment/models/collection.rb