Class: RS::Validable
- Inherits:
-
Object
- Object
- RS::Validable
- Defined in:
- lib/rs/models/waybill.rb
Overview
Class with errors and warnings.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#warnings ⇒ Object
Returns the value of attribute warnings.
Instance Method Summary collapse
-
#add_error(fld, msg) ⇒ Object
Add error to the specified field.
-
#add_warning(fld, msg) ⇒ Object
Add warning to the specified field.
-
#valid? ⇒ Boolean
Valid?.
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
6 7 8 |
# File 'lib/rs/models/waybill.rb', line 6 def errors @errors end |
#warnings ⇒ Object
Returns the value of attribute warnings.
6 7 8 |
# File 'lib/rs/models/waybill.rb', line 6 def warnings @warnings end |
Instance Method Details
#add_error(fld, msg) ⇒ Object
Add error to the specified field.
9 10 11 12 |
# File 'lib/rs/models/waybill.rb', line 9 def add_error(fld, msg) self.errors = {} unless self.errors self.errors[fld.to_sym] = msg end |
#add_warning(fld, msg) ⇒ Object
Add warning to the specified field.
15 16 17 18 |
# File 'lib/rs/models/waybill.rb', line 15 def add_warning(fld, msg) self.warnings = {} unless self.warnings self.warnings[fld.to_sym] = msg end |
#valid? ⇒ Boolean
Valid?
21 22 23 |
# File 'lib/rs/models/waybill.rb', line 21 def valid? self.errors.nil? or self.errors.empty? end |