Class: Ward::Support::Result
- Inherits:
-
Object
- Object
- Ward::Support::Result
- Defined in:
- lib/ward/support/result.rb
Overview
Used when validating objects which don’t include the Validation module. Contains the results of running a ValidatorSet against a record, and any errors which occurred.
Instance Attribute Summary collapse
-
#errors ⇒ Ward:Errors
readonly
Returns the errors which were found when validating.
Instance Method Summary collapse
-
#fail? ⇒ Boolean
Returns true if the validations failed.
-
#initialize(errors) ⇒ Result
constructor
Creates a new Result instance.
-
#pass? ⇒ Boolean
(also: #valid?)
Returns true if the validations passed.
Constructor Details
#initialize(errors) ⇒ Result
Creates a new Result instance.
24 25 26 27 |
# File 'lib/ward/support/result.rb', line 24 def initialize(errors) @errors = errors @result = errors.empty? end |
Instance Attribute Details
#errors ⇒ Ward:Errors (readonly)
Returns the errors which were found when validating.
An Errors instance will always be returned, even if there were no errors with the record.
17 18 19 |
# File 'lib/ward/support/result.rb', line 17 def errors @errors end |
Instance Method Details
#fail? ⇒ Boolean
Returns true if the validations failed.
43 44 45 |
# File 'lib/ward/support/result.rb', line 43 def fail? not pass? end |
#pass? ⇒ Boolean Also known as: valid?
Returns true if the validations passed.
33 34 35 |
# File 'lib/ward/support/result.rb', line 33 def pass? @result end |