You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.
Class: Aws::Resources::CollectionReturns the first resource from the collection.
Specifies the maximum number of items to enumerate.
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ ObjectThis method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
73 74 75 76 77 78 79 80 81 82
# File 'aws-sdk-resources/lib/aws-sdk-resources/collection.rb', line 73 def method_missing(method_name, *args, &block) if respond_to?(method_name) Batch.validate_batch_args!(args) batches.each do |batch| batch.send(method_name, *args, &block) end else super end endInstance Method Details #each(&block) ⇒ Enumerator<Resource>
16 17 18 19 20 21 22
# File 'aws-sdk-resources/lib/aws-sdk-resources/collection.rb', line 16 def each(&block) if block_given? batches.each { |batch| batch.each(&block) } else self end end#first(count = 1) ⇒ Resource, Batch
Returns the first resource from the collection.
resource = collection.first
If you pass a count, then the first count
resources are returned in a single batch. See the resource specific batch documentation for a list of supported batch methods.
resources = collection.first(10)
resources.delete
55 56 57 58 59 60 61
# File 'aws-sdk-resources/lib/aws-sdk-resources/collection.rb', line 55 def first(count = 1) if count == 1 limit(1).to_a.first else Batch.new(resource_class, limit(count).to_a) end end#limit(limit) ⇒ Collection
Specifies the maximum number of items to enumerate.
collection.limit(10).each do |resource|
end
39 40 41
# File 'aws-sdk-resources/lib/aws-sdk-resources/collection.rb', line 39 def limit(limit) self.class.new(@operation, @options.merge(limit: limit)) end
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4