Sha256: b711c1d32bc4031140c4882d9b7a96ed40ae74f97ab0e47fd06700ee041da1e4

Contents?: true

Size: 457 Bytes

Versions: 1

Compression:

Stored size: 457 Bytes

Contents

module TimeCamp
  class EntryCollection < ResourceCollection
    def initialize(response)
      @resources = response.map{|entry| Entry.new(entry) }
    end

    def find(entry_id)
      return @resources.select{ |entry| entry.id == entry_id }.try(:first)
    end

    def self.parse(response)
      return EntryCollection.new([]) if response.blank?
      return response.is_a?(Array) ? EntryCollection.new(response) : Entry.new(response)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-timecamp-0.0.2 lib/ruby-timecamp/resources/entry_collection.rb