You are viewing documentation for version 3 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Module: Seahorse::Client::HandlerBuilder

Included in:
Base, Plugin, Request
Defined in:
gems/aws-sdk-core/lib/seahorse/client/handler_builder.rb

Overview

This module provides the ability to add handlers to a class or module. The including class or extending module must respond to #handlers, returning a HandlerList.

Instance Method Summary collapse

Instance Method Details

#handle(*args, &block) ⇒ Object Also known as: handler



24
25
26
27
28
# File 'gems/aws-sdk-core/lib/seahorse/client/handler_builder.rb', line 24

def handle(*args, &block)
  options = args.last.is_a?(Hash) ? args.pop : {}
  handler_class = block ? handler_for(*args, &block) : args.first
  handlers.add(handler_class, options)
end

#handle_request(*args, &block) ⇒ Object



9
10
11
12
13
14
# File 'gems/aws-sdk-core/lib/seahorse/client/handler_builder.rb', line 9

def handle_request(*args, &block)
  handler(*args) do |context|
    block.call(context)
    @handler.call(context)
  end
end

#handle_response(*args, &block) ⇒ Object



16
17
18
19
20
21
22
# File 'gems/aws-sdk-core/lib/seahorse/client/handler_builder.rb', line 16

def handle_response(*args, &block)
  handler(*args) do |context|
    resp = @handler.call(context)
    block.call(resp) if resp.context.http_response.status_code > 0
    resp
  end
end