Class: Gcloud::Pubsub::Subscription::List

Inherits:
Array
  • Object
show all
Defined in:
lib/gcloud/pubsub/subscription/list.rb

Overview

Subscription::List is a special case Array with additional values.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arr = [], token = nil) ⇒ List

Create a new Subscription::List with an array of values.



30
31
32
33
# File 'lib/gcloud/pubsub/subscription/list.rb', line 30

def initialize arr = [], token = nil
  super arr
  @token = token
end

Instance Attribute Details

#tokenObject

If not empty, indicates that there are more subscriptions that match the request and this value should be passed to the next Gcloud::PubSub::Topic#subscriptions to continue.



26
27
28
# File 'lib/gcloud/pubsub/subscription/list.rb', line 26

def token
  @token
end

Class Method Details

.from_resp(resp, conn) ⇒ Object

New Subscription::List from a response object.



37
38
39
40
41
42
43
44
45
46
# File 'lib/gcloud/pubsub/subscription/list.rb', line 37

def self.from_resp resp, conn #:nodoc:
  subs = Array(resp.data["subscriptions"]).map do |gapi_object|
    if gapi_object.is_a? String
      Subscription.new_lazy gapi_object, conn
    else
      Subscription.from_gapi gapi_object, conn
    end
  end
  new subs, resp.data["nextPageToken"]
end