Class: Monban::ParamTransformer
- Inherits:
-
Object
- Object
- Monban::ParamTransformer
- Defined in:
- lib/monban/param_transformer.rb
Overview
Parameter transformer. Sanitizes and transforms parameter values
Instance Method Summary collapse
-
#initialize(params, transformations) ⇒ ParamTransformer
constructor
Initialize parameter transformer.
-
#to_h ⇒ Object
Returns the transformed parameters.
Constructor Details
#initialize(params, transformations) ⇒ ParamTransformer
Initialize parameter transformer
8 9 10 11 |
# File 'lib/monban/param_transformer.rb', line 8 def initialize(params, transformations) @params = params @transformations = transformations end |
Instance Method Details
#to_h ⇒ Object
Returns the transformed parameters
14 15 16 17 18 |
# File 'lib/monban/param_transformer.rb', line 14 def to_h sanitized_params.each_with_object({}) do |(key, value), hash| hash[key] = transform(key, value) end end |