lib/soaspec/exchange_handlers/exchange_handler.rb in soaspec-0.1.18 vs lib/soaspec/exchange_handlers/exchange_handler.rb in soaspec-0.2.0

- old
+ new

@@ -14,22 +14,19 @@ # Explicitly defined elements for which a path has been predefined def elements public_methods.select { |i| i[/__custom_path_.+/] } end - # Set the default hash representing data to be used in making a request - # This will set the @request_option instance variable too - def default_hash=(hash) - @request_option = :hash - @default_hash = Soaspec.always_use_keys? ? hash.transform_keys_to_symbols : hash - end - # 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 + 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 end # Set Api handler used by Exchange class to this handler # @return [Self] @@ -43,10 +40,17 @@ def to_s use @name.to_s end + # Set the default hash representing data to be used in making a request + # This will set the @request_option instance variable too + def default_hash=(hash) + @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 @@ -110,8 +114,7 @@ # Request of API call. Either intended request or actual request def request(response) return "Request not yet sent Request option is #{@request_option}" unless response 'Specific API handler should implement this' end - end end \ No newline at end of file