Class Amazon::AWS::Operation
In: lib/amazon/aws.rb
Parent: Object

This is the base class of all AWS operations.

Methods

batch   new  

Constants

OPERATIONS = %w[ BrowseNodeLookup CustomerContentLookup CustomerContentSearch Help ItemLookup ItemSearch ListLookup ListSearch MultipleOperation SellerListingLookup SellerListingSearch SellerLookup SimilarityLookup TagLookup TransactionLookup VehiclePartLookup VehiclePartSearch VehicleSearch CartAdd CartClear CartCreate CartGet CartModify ]   These are the types of AWS operation currently implemented by Ruby/AWS.

External Aliases

response_group= -> response_group_orig=
  Make sure we can still get to the old @response_group= writer method.

Attributes

kind  [R] 
params  [RW] 
response_group  [RW] 

Public Class methods

[Source]

# File lib/amazon/aws.rb, line 617
      def initialize(parameters)

        op_kind = self.class.to_s.sub( /^.*::/, '' )

        raise "Bad operation: #{op_kind}" unless OPERATIONS.include?( op_kind )

        if ResponseGroup::DEFAULT.key?( op_kind )
          response_group =
            ResponseGroup.new( ResponseGroup::DEFAULT[op_kind] )
        else
          response_group = nil
        end

        if op_kind =~ /^Cart/
          @params = parameters
        else
          @params = Hash.new { |hash, key| hash[key] = [] }
          @response_group = Hash.new { |hash, key| hash[key] = [] }

          unless op_kind == 'MultipleOperation'
            @params[op_kind] = [ parameters ]
            @response_group[op_kind] = [ response_group ]
          end
        end

        @kind = op_kind
      end

Public Instance methods

Group together operations of the same class in a batch request. operations should be either an operation of the same class as self or an array of such operations.

If you need to batch operations of different classes, use a MultipleOperation instead.

Example:

 is = ItemSearch.new( 'Books', { 'Title' => 'ruby programming' } )
 is2 = ItemSearch.new( 'Music', { 'Artist' => 'stranglers' } )
 is.response_group = ResponseGroup.new( :Small )
 is2.response_group = ResponseGroup.new( :Tracks )
 is.batch( is2 )

Please see MultipleOperation.new for implementation details that also apply to batched operations.

[Source]

# File lib/amazon/aws.rb, line 680
      def batch(*operations)

        operations.flatten.each do |op|

          unless self.class == op.class
            raise BatchError, "You can't batch operations of different classes. Use class MultipleOperation."
          end

          # Add the operation's single element array containing the parameter
          # hash to the array.
          #
          @params[op.kind].concat( op.params[op.kind] )

          # Add the operation's response group array to the array.
          #
          @response_group[op.kind].concat( op.response_group[op.kind] )
        end

      end

[Validate]