Module: Soaspec::ExchangeProperties
- Included in:
- Exchange
- Defined in:
- lib/soaspec/exchange/exchange_properties.rb
Overview
Convenience methods to set Exchange specific properties Will be used when creating a subclass of Exchange
Instance Method Summary collapse
-
#default_handler(handler_class, name = handler_class.to_s, params = {}) ⇒ Object
Set default exchange handler for this exchange.
-
#expect_positive_status(retry_count: 3) ⇒ Object
Set retry_for_success to true, retrying response until a successful status code is returned.
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
25 26 27 28 29 30 31 32 |
# File 'lib/soaspec/exchange/exchange_properties.rb', line 25 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
36 37 38 39 |
# File 'lib/soaspec/exchange/exchange_properties.rb', line 36 def expect_positive_status(retry_count: 3) define_method('retry_count') { retry_count } define_method('retry_for_success?') { true } end |