Class: OracleHcm::ResourceList

Inherits:
Resource
  • Object
show all
Defined in:
lib/oracle_hcm/resource_list.rb

Overview

A ResourceList is a helper object that makes it easy to poll through paginated resources.

Instance Attribute Summary collapse

Attributes inherited from Resource

#data

Instance Method Summary collapse

Methods inherited from Resource

cached_property, #canonical_id, child_resource, #link, property, resource_name, #resource_name, #resource_url, #uri

Constructor Details

#initialize(data, offset, limit, method, resource, client, parent = nil) ⇒ ResourceList

Returns a new instance of ResourceList.



9
10
11
12
13
14
15
16
# File 'lib/oracle_hcm/resource_list.rb', line 9

def initialize(data, offset, limit, method, resource, client, parent = nil)
  super(data, client)
  @limit = limit
  @offset = offset
  @method = method
  @resource = resource
  @parent = parent
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/oracle_hcm/resource_list.rb', line 7

def client
  @client
end

#limitObject (readonly)

Returns the value of attribute limit.



7
8
9
# File 'lib/oracle_hcm/resource_list.rb', line 7

def limit
  @limit
end

#methodObject (readonly)

Returns the value of attribute method.



7
8
9
# File 'lib/oracle_hcm/resource_list.rb', line 7

def method
  @method
end

#offsetObject (readonly)

Returns the value of attribute offset.



7
8
9
# File 'lib/oracle_hcm/resource_list.rb', line 7

def offset
  @offset
end

#parentObject (readonly)

Returns the value of attribute parent.



7
8
9
# File 'lib/oracle_hcm/resource_list.rb', line 7

def parent
  @parent
end

#resourceObject (readonly)

Returns the value of attribute resource.



7
8
9
# File 'lib/oracle_hcm/resource_list.rb', line 7

def resource
  @resource
end

Instance Method Details

#itemsObject



22
23
24
25
26
# File 'lib/oracle_hcm/resource_list.rb', line 22

def items
  @data.fetch("items").map { |item|
    resource.new(item, client, parent)
  }
end

#nextObject



18
19
20
# File 'lib/oracle_hcm/resource_list.rb', line 18

def next
  client.send(method, limit: limit, offset: offset + limit)
end