Sha256: 3ef4b42449ec6b3e469141c404f531192586fcf77d4742589cade5d91a67a41b

Contents?: true

Size: 1.66 KB

Versions: 1215

Compression:

Stored size: 1.66 KB

Contents

module Seahorse
  module Client
    module Plugins

      # Defines a helper method for each API operation that builds and
      # sends the named request.
      #
      # # Helper Methods
      #
      # This plugin adds a helper method that lists the available API
      # operations.
      #
      #     client.operation_names
      #     #=> [:api_operation_name1, :api_operation_name2, ...]
      #
      # Additionally, it adds a helper method for each operation.  This helper
      # handles building and sending the appropriate {Request}.
      #
      #     # without OperationMethods plugin
      #     req = client.build_request(:api_operation_name, request_params)
      #     resp = req.send_request
      #
      #     # using the helper method defined by OperationMethods
      #     resp = client.api_operation_name(request_params)
      #
      class OperationMethods < Plugin

        def after_initialize(client)
          unless client.respond_to?(:operation_names)
            client.class.mutex.synchronize do
              unless client.respond_to?(:operation_names)
                add_operation_helpers(client, client.config.api.operation_names)
              end
            end
          end
        end

        def add_operation_helpers(client, operations)
          operations.each do |name|
            client.class.send(:define_method, name) do |*args, &block|
              params = args[0] || {}
              send_options = args[1] || {}
              build_request(name, params).send_request(send_options, &block)
            end
          end
          client.class.send(:define_method, :operation_names) { operations }
        end

      end
    end
  end
end

Version data entries

1,215 entries across 1,215 versions & 2 rubygems

Version Path
aws-sdk-core-2.11.612 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.611 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.610 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.609 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.608 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.607 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.606 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.605 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.604 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.603 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.602 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.601 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.600 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.599 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.598 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.597 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.596 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.595 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.594 lib/seahorse/client/plugins/operation_methods.rb
aws-sdk-core-2.11.593 lib/seahorse/client/plugins/operation_methods.rb