lib/harvesting/models/tasks.rb in harvesting-0.2.0 vs lib/harvesting/models/tasks.rb in harvesting-0.3.0
- old
+ new
@@ -1,45 +1,18 @@
module Harvesting
module Models
- class Tasks < Base
- include Harvesting::Enumerable
- extend Forwardable
+ class Tasks < HarvestRecordCollection
- attributed :per_page,
- :total_pages,
- :total_entries,
- :next_page,
- :previous_page,
- :page,
- :links
-
- attr_reader :entries
-
- def initialize(attrs, opts = {})
- super(attrs.reject {|k,v| k == "tasks" }, opts)
- @api_page = attrs
+ def initialize(attrs, query_opts = {}, opts = {})
+ super(attrs.reject {|k,v| k == "tasks" }, query_opts, opts)
@entries = attrs["tasks"].map do |entry|
Task.new(entry, client: opts[:client])
end
end
- # def each
- # @entries.each_with_index do |time_entry, index|
- # yield(time_entry)
- # end
- # end
- def page
- @attributes['page']
- end
-
- def size
- total_entries
- end
-
def fetch_next_page
- new_page = page + 1
- @entries += client.tasks(page: new_page).entries
- @attributes['page'] = new_page
+ @entries += harvest_client.tasks(next_page_query_opts).entries
+ @attributes['page'] = page + 1
end
end
end
end