Class: Paraphrase::ParamsFilter
- Inherits:
-
Object
- Object
- Paraphrase::ParamsFilter
- Defined in:
- lib/paraphrase/params_filter.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(unfiltered_params, keys) ⇒ ParamsFilter
constructor
A new instance of ParamsFilter.
Constructor Details
#initialize(unfiltered_params, keys) ⇒ ParamsFilter
Returns a new instance of ParamsFilter.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/paraphrase/params_filter.rb', line 5 def initialize(unfiltered_params, keys) @params = unfiltered_params.with_indifferent_access.slice(*keys) @result = @params.inject(HashWithIndifferentAccess.new) do |result, (key, value)| value = @params[key] if respond_to?(key) value = send(key) end value = scrub(value) if value.present? result[key] = value end result end end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/paraphrase/params_filter.rb', line 3 def params @params end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
3 4 5 |
# File 'lib/paraphrase/params_filter.rb', line 3 def result @result end |