class ActionController::Parameters
def fetch(key, *args)
params.fetch(:none, "Francesco") # => "Francesco"
params.fetch(:none, {}) # => #
params.fetch(:none) # => ActionController::ParameterMissing: param is missing or the value is empty: none
params.fetch(:person) # => #
params = ActionController::Parameters.new(person: { name: "Francesco" })
is given, then that will be run and its result returned.
instance of +ActionController::Parameters+ if possible); if a block
if a second argument is given, then that is returned (converted to an
it will raise an ActionController::ParameterMissing error;
can't be found, there are several options: With no other arguments,
Returns a parameter for the given +key+. If the +key+
def fetch(key, *args) convert_value_to_parameters( @parameters.fetch(key) { if block_given? yield else args.fetch(0) { raise ActionController::ParameterMissing.new(key, @parameters.keys) } end } ) end