Class: Nylas::DeltasCollection
- Inherits:
-
Collection
- Object
- Collection
- Nylas::DeltasCollection
- Extended by:
- Forwardable
- Defined in:
- lib/nylas/deltas_collection.rb
Overview
Special collection for delta objects
Instance Attribute Summary collapse
-
#deltas ⇒ Object
Returns the value of attribute deltas.
Attributes inherited from Collection
Instance Method Summary collapse
-
#execute ⇒ Detlas
Retrieves the data from the API for the particular constraints.
-
#initialize(api:, constraints: nil, model: Deltas) ⇒ DeltasCollection
constructor
A new instance of DeltasCollection.
- #latest ⇒ Object
- #latest_cursor ⇒ Object
- #next_page ⇒ Object
- #since(cursor) ⇒ Object
Methods inherited from Collection
#count, #create, #each, #expanded, #find, #find_each, #find_model, #find_raw, #ids, #limit, #more_pages?, #new, #offset, #raw, #resources_path, #search, #to_be_executed, #where
Constructor Details
#initialize(api:, constraints: nil, model: Deltas) ⇒ DeltasCollection
Returns a new instance of DeltasCollection.
12 13 14 |
# File 'lib/nylas/deltas_collection.rb', line 12 def initialize(api:, constraints: nil, model: Deltas) super(api: api, model: model, constraints: constraints) end |
Instance Attribute Details
#deltas ⇒ Object
Returns the value of attribute deltas.
6 7 8 |
# File 'lib/nylas/deltas_collection.rb', line 6 def deltas @deltas end |
Instance Method Details
#execute ⇒ Detlas
Retrieves the data from the API for the particular constraints
36 37 38 |
# File 'lib/nylas/deltas_collection.rb', line 36 def execute self.deltas ||= Deltas.new(**api.execute(**to_be_executed)) end |
#latest ⇒ Object
20 21 22 |
# File 'lib/nylas/deltas_collection.rb', line 20 def latest since(latest_cursor) end |
#latest_cursor ⇒ Object
16 17 18 |
# File 'lib/nylas/deltas_collection.rb', line 16 def latest_cursor api.execute(method: :post, path: "#{resources_path}/latest_cursor")[:cursor] end |
#next_page ⇒ Object
28 29 30 31 32 |
# File 'lib/nylas/deltas_collection.rb', line 28 def next_page(*) return nil if empty? where(cursor: cursor_end) end |
#since(cursor) ⇒ Object
24 25 26 |
# File 'lib/nylas/deltas_collection.rb', line 24 def since(cursor) where(cursor: cursor) end |