Class: Gcloud::Dns::Record::List
- Inherits:
-
Array
- Object
- Array
- Gcloud::Dns::Record::List
- Defined in:
- lib/gcloud/dns/record/list.rb
Overview
Record::List is a special case Array with additional values.
Instance Attribute Summary collapse
-
#token ⇒ Object
If not empty, indicates that there are more records that match the request and this value should be passed to continue.
Class Method Summary collapse
Instance Method Summary collapse
-
#all ⇒ Object
Retrieves all records by repeatedly loading pages until #next? returns false.
-
#initialize(arr = []) ⇒ List
constructor
Create a new Record::List with an array of Record instances.
-
#next ⇒ Object
Retrieve the next page of records.
-
#next? ⇒ Boolean
Whether there a next page of records.
Constructor Details
#initialize(arr = []) ⇒ List
Create a new Record::List with an array of Record instances.
31 32 33 |
# File 'lib/gcloud/dns/record/list.rb', line 31 def initialize arr = [] super arr end |
Instance Attribute Details
#token ⇒ Object
If not empty, indicates that there are more records that match the request and this value should be passed to continue.
27 28 29 |
# File 'lib/gcloud/dns/record/list.rb', line 27 def token @token end |
Class Method Details
.from_response(resp, zone) ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/gcloud/dns/record/list.rb', line 72 def self.from_response resp, zone records = new(Array(resp.data["rrsets"]).map do |gapi_object| Record.from_gapi gapi_object end) records.instance_eval do @token = resp.data["nextPageToken"] @zone = zone end records end |
Instance Method Details
#all ⇒ Object
Retrieves all records by repeatedly loading pages until #next? returns false. Returns the list instance for method chaining.
61 62 63 64 65 66 67 68 |
# File 'lib/gcloud/dns/record/list.rb', line 61 def all while next? next_records = self.next push(*next_records) self.token = next_records.token end self end |
#next ⇒ Object
Retrieve the next page of records.
43 44 45 46 47 |
# File 'lib/gcloud/dns/record/list.rb', line 43 def next return nil unless next? ensure_zone! @zone.records token: token end |
#next? ⇒ Boolean
Whether there a next page of records.
37 38 39 |
# File 'lib/gcloud/dns/record/list.rb', line 37 def next? !token.nil? end |