Class: Nylas::DeltasCollection

Inherits:
Collection show all
Extended by:
Forwardable
Defined in:
lib/nylas/deltas_collection.rb

Overview

Special collection for delta objects

Instance Attribute Summary collapse

Attributes inherited from Collection

#api, #constraints, #model

Instance Method Summary collapse

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

#deltasObject

Returns the value of attribute deltas.



6
7
8
# File 'lib/nylas/deltas_collection.rb', line 6

def deltas
  @deltas
end

Instance Method Details

#executeDetlas

Retrieves the data from the API for the particular constraints

Returns:

  • (Detlas)


36
37
38
# File 'lib/nylas/deltas_collection.rb', line 36

def execute
  self.deltas ||= Deltas.new(**api.execute(**to_be_executed))
end

#latestObject



20
21
22
# File 'lib/nylas/deltas_collection.rb', line 20

def latest
  since(latest_cursor)
end

#latest_cursorObject



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_pageObject



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