Class: OSA::Paginated

Inherits:
Object
  • Object
show all
Defined in:
lib/osa/util/paginated.rb

Instance Method Summary collapse

Constructor Details

#initialize(value, client) ⇒ Paginated

Returns a new instance of Paginated.



5
6
7
8
# File 'lib/osa/util/paginated.rb', line 5

def initialize(value, client)
  @value = value
  @client = client
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args) ⇒ Object (private)



27
28
29
# File 'lib/osa/util/paginated.rb', line 27

def method_missing(symbol, *args)
  @value.send(symbol, *args)
end

Instance Method Details

#allObject



16
17
18
19
20
21
22
23
24
# File 'lib/osa/util/paginated.rb', line 16

def all
  value = @value['value'].dup
  next_page = self.next
  until next_page.nil?
    value += next_page['value']
    next_page = next_page.next
  end
  value
end

#nextObject



10
11
12
13
14
# File 'lib/osa/util/paginated.rb', line 10

def next
  next_page = @value['@odata.nextLink']
  return nil if next_page.nil?
  Paginated.new(@client.get(next_page), @client)
end