lib/soaspec/exchange.rb in soaspec-0.1.18 vs lib/soaspec/exchange.rb in soaspec-0.2.0
- old
+ new
@@ -1,37 +1,12 @@
require_relative '../soaspec'
+require_relative 'exchange_properties'
-# Convenience methods to set Exchange specific properties
-module ExchangeAccessors
-
- # Set default exchange handler for this exchange
- # This is helpful for when you need a new exchange handler created for each exchange
- 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
-
# This represents a request / response pair
# Essentially, params in the exchange that are set are related to the request
# What is returned is related to the response
class Exchange
- extend ExchangeAccessors
+ extend ExchangeProperties
# Instance of ExchangeHandler for which this exchange is made
attr_accessor :exchange_handler
# How many times to retry for a success
attr_accessor :retry_count
\ No newline at end of file