Class: Fog::PagedCollection

Inherits:
Collection show all
Defined in:
lib/fog/core/collection.rb

Overview

Base class for collection classes whose ‘all’ method returns only a single page of results and passes the ‘Marker’ option along as self.filters

Instance Attribute Summary

Attributes inherited from Collection

#service

Instance Method Summary collapse

Methods inherited from Collection

#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json

Methods included from Attributes::ClassMethods

#_load, #aliases, #associations, #attribute, #attributes, #default_values, #has_many, #has_many_identities, #has_one, #has_one_identity, #identity, #ignore_attributes, #ignored_attributes, #masks

Methods included from Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #all_associations, #all_associations_and_attributes, #all_attributes, #associations, #attributes, #dup, #identity, #identity=, #identity_name, #masks, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Collection

Instance Method Details

#each(collection_filters = filters) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/fog/core/collection.rb', line 120

def each(collection_filters = filters)
  if block_given?
    Kernel.loop do
      break unless filters[:marker]
      page = all(collection_filters)
      # We need to explicitly use the base 'each' method here on the page,
      #  otherwise we get infinite recursion
      base_each = Fog::Collection.instance_method(:each)
      base_each.bind(page).call { |item| yield item }
    end
  end
  self
end