module Seahorse::Client::HandlerBuilder
def handle(*args, &block)
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
def handle_request(*args, &block)
def handle_request(*args, &block) handler(*args) do |context| block.call(context) @handler.call(context) end end
def handle_response(*args, &block)
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
def handler_for(name = nil, &block)
- Api: - private
def handler_for(name = nil, &block) if name const_set(name, new_handler(block)) else new_handler(block) end end
def new_handler(block)
- Api: - private
def new_handler(block) Class.new(Handler) do define_method(:call, &block) end end