instance method
transform_values
Ruby on Rails 5.2.8.1
Since v4.2.9Signature
transform_values()
Returns a new ActionController::Parameters with the results of running block once for every value. The keys are unchanged.
params = ActionController::Parameters.new(a: 1, b: 2, c: 3) params.transform_values { |x| x * 2 } # => <ActionController::Parameters {"a"=>2, "b"=>4, "c"=>6} permitted: false>
Source
# File actionpack/lib/action_controller/metal/strong_parameters.rb, line 647
def transform_values
return to_enum(:transform_values) unless block_given?
new_instance_with_inherited_permitted_status(
@parameters.transform_values { |v| yield convert_value_to_parameters(v) }
)
end
Defined in actionpack/lib/action_controller/metal/strong_parameters.rb line 647
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionController::Parameters