Class: Audiences::Scim::ResourcesQuery
- Inherits:
-
Object
- Object
- Audiences::Scim::ResourcesQuery
- Includes:
- Enumerable
- Defined in:
- lib/audiences/scim/resources_query.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
- #all ⇒ Object
- #each(all: false, &block) ⇒ Object
-
#initialize(client, resource:, **options) ⇒ ResourcesQuery
constructor
A new instance of ResourcesQuery.
- #next_index ⇒ Object
- #next_page ⇒ Object
- #next_page? ⇒ Boolean
- #per_page ⇒ Object
- #resources ⇒ Object
- #start_index ⇒ Object
- #total_results ⇒ Object
Constructor Details
#initialize(client, resource:, **options) ⇒ ResourcesQuery
Returns a new instance of ResourcesQuery.
14 15 16 17 18 |
# File 'lib/audiences/scim/resources_query.rb', line 14 def initialize(client, resource:, **) @client = client @resource = resource @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/audiences/scim/resources_query.rb', line 12 def @options end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
12 13 14 |
# File 'lib/audiences/scim/resources_query.rb', line 12 def resource @resource end |
Instance Method Details
#all ⇒ Object
20 21 22 |
# File 'lib/audiences/scim/resources_query.rb', line 20 def all to_enum(:each, all: true) end |
#each(all: false, &block) ⇒ Object
24 25 26 27 |
# File 'lib/audiences/scim/resources_query.rb', line 24 def each(all: false, &block) resources.each(&block) next_page&.each(all: true, &block) if all end |
#next_index ⇒ Object
49 50 51 |
# File 'lib/audiences/scim/resources_query.rb', line 49 def next_index start_index + per_page end |
#next_page ⇒ Object
53 54 55 56 57 |
# File 'lib/audiences/scim/resources_query.rb', line 53 def next_page return unless next_page? ResourcesQuery.new(@client, resource: @resource, **@options, startIndex: next_index) end |
#next_page? ⇒ Boolean
33 34 35 |
# File 'lib/audiences/scim/resources_query.rb', line 33 def next_page? start_index + per_page <= total_results end |
#per_page ⇒ Object
41 42 43 |
# File 'lib/audiences/scim/resources_query.rb', line 41 def per_page response["itemsPerPage"].to_i end |
#resources ⇒ Object
29 30 31 |
# File 'lib/audiences/scim/resources_query.rb', line 29 def resources @resources ||= response.fetch("Resources", []) end |
#start_index ⇒ Object
37 38 39 |
# File 'lib/audiences/scim/resources_query.rb', line 37 def start_index response.fetch("startIndex", 1) end |
#total_results ⇒ Object
45 46 47 |
# File 'lib/audiences/scim/resources_query.rb', line 45 def total_results response["totalResults"].to_i end |