Sha256: c06ee0607ebe992cf892cd547dfe4af064c6884187c7d2111544d88fd2f58cb2

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 KB

Contents

# Convenience methods to set Exchange specific properties
# Will be used when creating a subclass of Exchange
module ExchangeProperties

  # Set default exchange handler for this exchange
  # This is helpful for when you need a new exchange handler created for each exchange
  # @param [Class] handler_class Class of ExchangeHandler to set Exchange to use
  # @param [String] name Name to call handler when it's instantiated (Defaults to class name)
  # @param [Hash] params Hash of parameters to set for instance of ExchangeHandler
  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

  # Set retry_for_success to true, retrying response until a successful status code is returned
  def expect_positive_status(retry_count: 3)
    define_method('retry_count') do
      retry_count
    end
    define_method('retry_for_success?') do
      true
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
soaspec-0.2.8 lib/soaspec/exchange_properties.rb
soaspec-0.2.7 lib/soaspec/exchange_properties.rb
soaspec-0.2.5 lib/soaspec/exchange_properties.rb
soaspec-0.2.4 lib/soaspec/exchange_properties.rb
soaspec-0.2.3 lib/soaspec/exchange_properties.rb
soaspec-0.2.2 lib/soaspec/exchange_properties.rb
soaspec-0.2.1 lib/soaspec/exchange_properties.rb
soaspec-0.2.0 lib/soaspec/exchange_properties.rb