Module: ExchangeAccessors

Included in:
Exchange
Defined in:
lib/soaspec/exchange.rb

Overview

Convenience methods to set Exchange specific properties

Instance Method Summary collapse

Instance Method Details

#default_handler(handler_class, name = handler_class.to_s, params = '') ⇒ Object

Set default exchange handler for this exchange This is helpful for when you need a new exchange handler created for each exchange



8
9
10
11
12
13
14
15
# File 'lib/soaspec/exchange.rb', line 8

def default_handler(handler_class, name = handler_class.to_s, params = '')
  define_method('default_handler_used') do
    params_used = Hash[params.map do |k, param|
      [k, param.is_a?(String) ? ERB.new(param).result(binding) : param]
    end]
    handler_class.new name, params_used
  end
end

#expect_positive_status(retry_count: 3) ⇒ Object

Set retry_for_success to true, retrying response until a successful status code is returned



18
19
20
21
22
23
24
25
# File 'lib/soaspec/exchange.rb', line 18

def expect_positive_status(retry_count: 3)
  define_method('retry_count') do
    retry_count
  end
  define_method('retry_for_success?') do
    true
  end
end