Class: Formalism::Form::Outcome
- Inherits:
-
Object
- Object
- Formalism::Form::Outcome
- Defined in:
- lib/formalism/form/outcome.rb
Overview
Private class for results
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(errors, result = nil) ⇒ Outcome
constructor
A new instance of Outcome.
- #result ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(errors, result = nil) ⇒ Outcome
Returns a new instance of Outcome.
10 11 12 13 |
# File 'lib/formalism/form/outcome.rb', line 10 def initialize(errors, result = nil) @errors = errors @result = result end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
8 9 10 |
# File 'lib/formalism/form/outcome.rb', line 8 def errors @errors end |
Instance Method Details
#result ⇒ Object
19 20 21 22 23 |
# File 'lib/formalism/form/outcome.rb', line 19 def result raise ValidationError, errors if errors.any? @result end |
#success? ⇒ Boolean
15 16 17 |
# File 'lib/formalism/form/outcome.rb', line 15 def success? @errors.empty? end |