Class: Committee::Test::ExceptParameter::BaseHashParameterHandler
- Inherits:
-
Object
- Object
- Committee::Test::ExceptParameter::BaseHashParameterHandler
- Includes:
- StringDummyLookup
- Defined in:
- lib/committee/test/except_parameter.rb
Overview
Base handler for parameters stored in hash-like structures. Subclasses implement #get_storage and optionally #dummy_value_for.
Direct Known Subclasses
Instance Method Summary collapse
-
#apply(param_names) ⇒ void
Apply dummy values to parameters.
-
#initialize(request, committee_options) ⇒ BaseHashParameterHandler
constructor
A new instance of BaseHashParameterHandler.
-
#restore ⇒ void
Restore original parameter values.
Constructor Details
#initialize(request, committee_options) ⇒ BaseHashParameterHandler
Returns a new instance of BaseHashParameterHandler.
114 115 116 117 118 |
# File 'lib/committee/test/except_parameter.rb', line 114 def initialize(request, ) @request = request @committee_options = @original_values = {} end |
Instance Method Details
#apply(param_names) ⇒ void
This method returns an undefined value.
Apply dummy values to parameters
123 124 125 126 127 128 129 130 131 132 |
# File 'lib/committee/test/except_parameter.rb', line 123 def apply(param_names) storage = get_storage return unless storage param_names.each do |param_name| key = param_name.to_s @original_values[key] = storage[key] storage[key] ||= dummy_value_for(key) end end |
#restore ⇒ void
This method returns an undefined value.
Restore original parameter values
136 137 138 139 140 141 142 143 |
# File 'lib/committee/test/except_parameter.rb', line 136 def restore storage = get_storage return unless storage @original_values.each do |key, value| value.nil? ? storage.delete(key) : storage[key] = value end end |