Class: Harvesting::Models::TimeEntries

Inherits:
HarvestRecordCollection show all
Defined in:
lib/harvesting/models/time_entries.rb

Instance Attribute Summary

Attributes inherited from HarvestRecordCollection

#entries

Attributes inherited from Base

#attributes, #harvest_client

Instance Method Summary collapse

Methods inherited from HarvestRecordCollection

#next_page_query_opts, #page, #size

Methods included from Enumerable

#each

Methods inherited from Base

#create, #delete, #fetch, get, #save, #to_hash, #update

Constructor Details

#initialize(attrs, query_opts = {}, opts = {}) ⇒ TimeEntries

Returns a new instance of TimeEntries.



5
6
7
8
9
10
# File 'lib/harvesting/models/time_entries.rb', line 5

def initialize(attrs, query_opts = {}, opts = {})
  super(attrs.reject {|k,v| k == "time_entries" }, query_opts, opts)
  @entries = attrs["time_entries"].map do |entry|
    TimeEntry.new(entry, harvest_client: opts[:harvest_client])
  end
end

Instance Method Details

#fetch_next_pageObject



12
13
14
15
# File 'lib/harvesting/models/time_entries.rb', line 12

def fetch_next_page
  @entries += harvest_client.time_entries(next_page_query_opts).entries
  @attributes['page'] = page + 1
end