Class: Brivo::Collection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/brivo/collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(application, api_path, model) ⇒ Collection

Returns a new instance of Collection.



7
8
9
10
11
12
13
14
# File 'lib/brivo/collection.rb', line 7

def initialize application, api_path, model
  @application = application
  @api_path = api_path
  @model = model
  @collection = []

  fetch_collection
end

Instance Method Details

#each(&block) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/brivo/collection.rb', line 17

def each(&block)
  total_count = @total_count
  while @collection.count < total_count do
    collection_count = @collection.count
    fetch_collection(offset: collection_count)
  end

  @collection.each(&block)
end