Class: Protocol::Content::Parameters::Result
- Inherits:
-
Object
- Object
- Protocol::Content::Parameters::Result
- Defined in:
- lib/protocol/content/parameters/result.rb
Overview
The result of parsing and validating content parameters.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
The validation errors.
-
#value ⇒ Object
readonly
The converted and filtered value.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Fetch an entry from the result value.
-
#dig(*path) ⇒ Object
Fetch an entry nested within the result value.
-
#initialize(value, errors) ⇒ Result
constructor
Initialize the result.
-
#valid? ⇒ Boolean
Whether the parameters are valid.
Constructor Details
#initialize(value, errors) ⇒ Result
Initialize the result.
14 15 16 17 |
# File 'lib/protocol/content/parameters/result.rb', line 14 def initialize(value, errors) @value = value @errors = errors.freeze end |
Instance Attribute Details
#errors ⇒ Object (readonly)
The validation errors.
23 24 25 |
# File 'lib/protocol/content/parameters/result.rb', line 23 def errors @errors end |
#value ⇒ Object (readonly)
The converted and filtered value.
20 21 22 |
# File 'lib/protocol/content/parameters/result.rb', line 20 def value @value end |
Instance Method Details
#[](key) ⇒ Object
Fetch an entry from the result value.
28 29 30 |
# File 'lib/protocol/content/parameters/result.rb', line 28 def [](key) return @value[key] end |
#dig(*path) ⇒ Object
Fetch an entry nested within the result value.
35 36 37 |
# File 'lib/protocol/content/parameters/result.rb', line 35 def dig(*path) return @value.dig(*path) end |
#valid? ⇒ Boolean
Whether the parameters are valid.
41 42 43 |
# File 'lib/protocol/content/parameters/result.rb', line 41 def valid? return @errors.empty? end |