class Aws::Resources::Operations::HasManyOperation
Attributes
builder[R]
@return [Builder]
limit_key[R]
@return [Symbol, nil]
Public Class Methods
new(options)
click to toggle source
@option options [required, Request] :request @option options [required, Builder] :builder @option options [Symbol] :limit_key
Calls superclass method
Aws::Resources::Operations::ResourceOperation.new
# File lib/aws-sdk-resources/operations.rb, line 97 def initialize(options) @limit_key = options[:limit_key] super end
Public Instance Methods
batches(options, &block)
click to toggle source
@api private @return [Enumerator<Batch>]
# File lib/aws-sdk-resources/operations.rb, line 117 def batches(options, &block) if options[:limit] enum_for(:limited_batches, options[:limit], options, &block) else enum_for(:all_batches, options, &block) end end
call(options)
click to toggle source
@option (see Base#call) @return [Collection]
# File lib/aws-sdk-resources/operations.rb, line 110 def call(options) validate_args!(options) Collection.new(self, options) end
Private Instance Methods
all_batches(options) { |build(merge(response:response))| ... }
click to toggle source
# File lib/aws-sdk-resources/operations.rb, line 138 def all_batches(options, &block) resp = @request.call(options) if resp.respond_to?(:each) resp.each do |response| yield(@builder.build(options.merge(response:response))) end else yield(@builder.build(options.merge(response:resp))) end end
limited_batches(limit, options) { |batch| ... }
click to toggle source
# File lib/aws-sdk-resources/operations.rb, line 149 def limited_batches(limit, options, &block) remaining = limit all_batches(options) do |batch| if batch.size < remaining yield(batch) remaining -= batch.size else yield(batch.first(remaining)) return end end end
validate_args!(options)
click to toggle source
# File lib/aws-sdk-resources/operations.rb, line 127 def validate_args!(options) args = options[:args] unless args.count == 0 || args.count == 1 msg = "wrong number of arguments (given #{args.count}, expected 0..1)" raise ArgumentError, msg end unless args[0].nil? || Hash === args[0] raise ArgumentError, "expected Hash, got #{args[0].class}" end end