lib/soaspec/exchange_handlers/exchange_handler.rb in soaspec-0.0.43 vs lib/soaspec/exchange_handlers/exchange_handler.rb in soaspec-0.0.44

- old
+ new

@@ -8,11 +8,11 @@ attr_reader :template_name # 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, options) + def initialize(name, options = {}) use @name = name end # Set Api handler used by Exchange class to this handler @@ -59,12 +59,19 @@ # 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 # @param [String] value Value to store def store(name, value) - define_singleton_method(name.to_s) do + define_singleton_method('__stored_val__' + name.to_s) do value end + end + + # Set instance variable and remove it from Hash + def set_remove_key(hash, key) + return unless hash.key? key + __send__("#{key}=", hash[key]) + hash.delete key end end end \ No newline at end of file