Class: Fog::AWS::IAM::PagedCollection

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/aws/iam/paged_collection.rb

Direct Known Subclasses

Groups, InstanceProfiles, ManagedPolicies, Policies, Roles

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inherited(klass) ⇒ Object



5
6
7
8
9
10
# File 'lib/fog/aws/iam/paged_collection.rb', line 5

def self.inherited(klass)
  klass.send(:attribute, :truncated, :aliases => 'IsTruncated', :type => :boolean)
  klass.send(:attribute, :marker,    :aliases => 'Marker')

  super
end

Instance Method Details

#each(options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/aws/iam/paged_collection.rb', line 16

def each(options={})
  limit = options[:limit] || 100

  if !block_given?
    self
  else
    subset = dup.all

    subset.each_entry { |f| yield f }

    while subset.truncated
      subset.
        all(:marker => subset.marker, :limit => limit).
        each_entry { |f| yield f }
    end

    self
  end
end

#each_entry(*args, &block) ⇒ Object



12
13
14
# File 'lib/fog/aws/iam/paged_collection.rb', line 12

def each_entry(*args, &block)
  to_a.each(*args, &block)
end