Class: Elmas::ResultSet

Inherits:
Object
  • Object
show all
Defined in:
lib/elmas/result_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parsed_response) ⇒ ResultSet

Returns a new instance of ResultSet.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/elmas/result_set.rb', line 7

def initialize(parsed_response)
  @parsed_response = parsed_response

  @records = if @parsed_response.results
               @parsed_response.results.map do |attributes|
                 resource_class.send(:new, attributes)
               end
             else
               [resource_class.send(:new, @parsed_response.result)]
             end
end

Instance Attribute Details

#recordsObject (readonly)

Returns the value of attribute records.



5
6
7
# File 'lib/elmas/result_set.rb', line 5

def records
  @records
end

Instance Method Details

#firstObject



28
29
30
# File 'lib/elmas/result_set.rb', line 28

def first
  records.first
end

#next_pageObject



19
20
21
22
23
24
25
26
# File 'lib/elmas/result_set.rb', line 19

def next_page
  return unless next_page_url
  next_page = Elmas.get(next_page_url, use_raw_path: true)
  return unless next_page

  response = Elmas::Response.new(next_page)
  response.results
end