Class: Grape::Validations::CoerceOptions
- Inherits:
-
Data
- Object
- Data
- Grape::Validations::CoerceOptions
- Defined in:
- lib/grape/validations/coerce_options.rb
Overview
Immutable value object describing how a parameter is coerced. Assembled by ValidationsSpec#coerce_options from the parsed type/coerce_with/ coerce_message declaration — never written by the user — and consumed by ParamsScope#check_coerce_with / ParamsScope#validate_coerce and by Validators::Validators::CoerceValidator (which receives it as its options argument).
All three fields may be nil (e.g. a remountable API evaluated on its base instance has no resolved type yet). coerce_method (not method) avoids shadowing Object#method.
Instance Attribute Summary collapse
-
#coerce_method ⇒ Object
readonly
Returns the value of attribute coerce_method.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type: nil, coerce_method: nil, message: nil) ⇒ CoerceOptions
constructor
A new instance of CoerceOptions.
Constructor Details
#initialize(type: nil, coerce_method: nil, message: nil) ⇒ CoerceOptions
Returns a new instance of CoerceOptions.
16 17 18 |
# File 'lib/grape/validations/coerce_options.rb', line 16 def initialize(type: nil, coerce_method: nil, message: nil) super end |
Instance Attribute Details
#coerce_method ⇒ Object (readonly)
Returns the value of attribute coerce_method
15 16 17 |
# File 'lib/grape/validations/coerce_options.rb', line 15 def coerce_method @coerce_method end |
#message ⇒ Object (readonly)
Returns the value of attribute message
15 16 17 |
# File 'lib/grape/validations/coerce_options.rb', line 15 def @message end |
#type ⇒ Object (readonly)
Returns the value of attribute type
15 16 17 |
# File 'lib/grape/validations/coerce_options.rb', line 15 def type @type end |