Sha256: 61be88d20c6382614d3ed5b7beed590c92776ff7ba4a4fc873a920b524f2f6a9
Contents?: true
Size: 856 Bytes
Versions: 1
Compression:
Stored size: 856 Bytes
Contents
# frozen_string_literal: true module ErpIntegration module Fulfil # The `Collection` class provides an enumerable interface for the `ApiResource` # to consume. It turns all the given items into the passed resource class. # # @example # $ Collection.new([...], resource_klass: ErpIntegration::Order) # # => <Collection @items=[<ErpIntegration::Order ... />, <ErpIntegration::Order ... />] class Collection include Enumerable attr_reader :items def initialize(items, resource_klass:) @items = items.map { |item| resource_klass.new(item) } end # The `each` method turns the `Collection` instance into an enumerable object. # For more information, see https://ruby-doc.org/core-3.0.2/Enumerable.html def each(&block) @items.each(&block) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
erp_integration-0.3.0 | lib/erp_integration/fulfil/collection.rb |