Class: Compel::Coercion::Result
- Inherits:
-
Object
- Object
- Compel::Coercion::Result
- Defined in:
- lib/compel/coercion/result.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#coerced ⇒ Object
readonly
Returns the value of attribute coerced.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(coerced, value, klass, coercion_error = nil) ⇒ Result
constructor
A new instance of Result.
- #valid? ⇒ Boolean
Constructor Details
#initialize(coerced, value, klass, coercion_error = nil) ⇒ Result
Returns a new instance of Result.
11 12 13 14 15 16 |
# File 'lib/compel/coercion/result.rb', line 11 def initialize(coerced, value, klass, coercion_error = nil) @coerced = coerced @value = value @klass = klass @error = coercion_error.nil? ? standard_error : coercion_error end |
Instance Attribute Details
#coerced ⇒ Object (readonly)
Returns the value of attribute coerced.
6 7 8 |
# File 'lib/compel/coercion/result.rb', line 6 def coerced @coerced end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
6 7 8 |
# File 'lib/compel/coercion/result.rb', line 6 def error @error end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
6 7 8 |
# File 'lib/compel/coercion/result.rb', line 6 def klass @klass end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/compel/coercion/result.rb', line 6 def value @value end |
Instance Method Details
#valid? ⇒ Boolean
18 19 20 |
# File 'lib/compel/coercion/result.rb', line 18 def valid? @error.nil? end |