lib/soaspec/exchange_handlers/exchange_handler.rb in soaspec-0.3.2 vs lib/soaspec/exchange_handlers/exchange_handler.rb in soaspec-0.3.3
- old
+ new
@@ -20,10 +20,12 @@
new.use
end
# @return [String] Name of the template file to be used in the API request
attr_reader :template_name
+ # @return [Symbol] Option used to generate Request Body. Either :hash or :template
+ attr_accessor :request_option
# Explicitly defined elements for which a path has been predefined
def elements
public_methods.select { |i| i[/__custom_path_.+/] }
end
@@ -31,11 +33,11 @@
# Set instance variable name
# @param [String, Symbol] name Name used when describing API test
# @param [Hash] _options Parameters defining handler. Used in descendants
def initialize(name = self.class.to_s, _options = {})
use
- @request_option = :hash
+ self.request_option = :hash
raise ArgumentError, 'Cannot define both template_name and default_hash' if respond_to?(:template_name_value) && respond_to?(:default_hash_value)
@template_name = respond_to?(:template_name_value) ? template_name_value : ''
@default_hash = respond_to?(:default_hash_value) ? default_hash_value : {}
@name = name
@@ -57,18 +59,18 @@
# Set the default hash representing data to be used in making a request
# This will set the @request_option instance variable too
# @param [Hash] hash Hash to send in request body by default
def default_hash=(hash)
- @request_option = :hash
+ self.request_option = :hash
@default_hash = Soaspec.always_use_keys? ? hash.transform_keys_to_symbols : hash
end
# Set the request option type and the template name
# Erb is used to parse the template file, executing Ruby code in `<%= %>` blocks to work out the final request
# @param [String] name Name of file inside 'template' folder excluding extension
def template_name=(name)
- @request_option = :template
+ self.request_option = :template
@template_name = name
end
# Stores a value in a method that can be accessed by the provided name
# @param [Symbol] name Name of method to use to access this value within handler