Class: SmartCore::Validator::Result
- Inherits:
-
Object
- Object
- SmartCore::Validator::Result
- Defined in:
- lib/smart_core/validator/result.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
(also: #to_h)
Returns the value of attribute data.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#failed ⇒ Object
(also: #failed?)
Returns the value of attribute failed.
Class Method Summary collapse
Instance Method Summary collapse
- #freeze ⇒ Object
-
#initialize(errors:, data:, failed:) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean
Constructor Details
#initialize(errors:, data:, failed:) ⇒ Result
Returns a new instance of Result.
17 18 19 20 21 |
# File 'lib/smart_core/validator/result.rb', line 17 def initialize(errors:, data:, failed:) self.errors = errors self.data = data self.failed = failed end |
Instance Attribute Details
#data ⇒ Object Also known as: to_h
Returns the value of attribute data.
5 6 7 |
# File 'lib/smart_core/validator/result.rb', line 5 def data @data end |
#errors ⇒ Object
Returns the value of attribute errors.
4 5 6 |
# File 'lib/smart_core/validator/result.rb', line 4 def errors @errors end |
#failed ⇒ Object Also known as: failed?
Returns the value of attribute failed.
6 7 8 |
# File 'lib/smart_core/validator/result.rb', line 6 def failed @failed end |
Class Method Details
.build_from_state(input_data, errors_controller) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/smart_core/validator/result.rb', line 8 def self.build_from_state(input_data, errors_controller) res = new( data: input_data, errors: errors_controller.errors, failed: errors_controller.validation_fails? ) res.freeze end |
Instance Method Details
#freeze ⇒ Object
27 28 29 30 31 32 |
# File 'lib/smart_core/validator/result.rb', line 27 def freeze super.tap do errors.freeze data.freeze end end |
#success? ⇒ Boolean
23 24 25 |
# File 'lib/smart_core/validator/result.rb', line 23 def success? !failed end |