Sha256: 8a5f84e876b2ee695b8dc22adfeacbe1302b31f0d1e99bc717c0567e2124b242

Contents?: true

Size: 598 Bytes

Versions: 5

Compression:

Stored size: 598 Bytes

Contents

module DPLibrary
  class Collection
    attr_accessor :collection_items

    def initialize(collection_response)
      set_values(collection_response)
    end

    def set_values(collection_response)
      @collection_items = []
      if (collection_response.is_a?(Array))
        @collection_items = collection_response.map {|h| create_collection_item(h)}
      else
        @collection_items << CollectionItem.new(collection_response)
      end
      @collection_items
    end

    def create_collection_item(collection_item_hash)
      CollectionItem.new(collection_item_hash)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
DPLibrary-0.1.0 lib/DPLibrary/collection.rb
DPLibrary-0.0.6 lib/DPLibrary/collection.rb
DPLibrary-0.0.5 lib/DPLibrary/collection.rb
DPLibrary-0.0.4 lib/DPLibrary/collection.rb
DPLibrary-0.0.3 lib/DPLibrary/collection.rb