instance method
transform_values
Ruby on Rails 5.0.7.2
Since v4.2.11.3Signature
transform_values(&block)
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>
Parameters
-
blockblock
Source
# File actionpack/lib/action_controller/metal/strong_parameters.rb, line 652
def transform_values(&block)
if block
new_instance_with_inherited_permitted_status(
@parameters.transform_values(&block)
)
else
@parameters.transform_values
end
end
Defined in actionpack/lib/action_controller/metal/strong_parameters.rb line 652
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionController::Parameters