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



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

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



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

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

#handle_response(*args, &block) ⇒ Object



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

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