Class: Cuprum::Rails::Errors::MissingParameter

Inherits:
Error
  • Object
show all
Defined in:
lib/cuprum/rails/errors/missing_parameter.rb

Overview

Error class when a parameters hash does not include the expected keys.

Constant Summary collapse

TYPE =

Short string used to identify the type of error.

'cuprum.rails.errors.missing_parameter'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameter_name:, parameters:) ⇒ MissingParameter

Returns a new instance of MissingParameter.

Parameters:

  • parameter_name (String, Symbol)

    the name of the missing parameter.

  • parameters (Hash)

    the received parameters.



13
14
15
16
17
18
19
20
21
# File 'lib/cuprum/rails/errors/missing_parameter.rb', line 13

def initialize(parameter_name:, parameters:)
  @parameter_name = parameter_name
  @parameters     = parameters

  super(
    message:        default_message,
    parameter_name: parameter_name
  )
end

Instance Attribute Details

#parameter_nameString, Symbol (readonly)

Returns the name of the missing parameter.

Returns:

  • (String, Symbol)

    the name of the missing parameter.



24
25
26
# File 'lib/cuprum/rails/errors/missing_parameter.rb', line 24

def parameter_name
  @parameter_name
end

#parametersHash (readonly)

Returns the received parameters.

Returns:

  • (Hash)

    the received parameters.



27
28
29
# File 'lib/cuprum/rails/errors/missing_parameter.rb', line 27

def parameters
  @parameters
end