@return [Builder]
@return [Symbol, nil]
@option options [required, Request] :request @option options [required, Builder] :builder @option options [Symbol] :limit_key
# File lib/aws-sdk-resources/operations.rb, line 97 def initialize(options) @limit_key = options[:limit_key] super end
@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
@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
# 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
# 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
# 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