Class: Errapi::ValidationError
- Inherits:
-
Object
- Object
- Errapi::ValidationError
- Defined in:
- lib/errapi/validation_error.rb
Instance Attribute Summary collapse
-
#check_value ⇒ Object
Returns the value of attribute check_value.
-
#checked_value ⇒ Object
Returns the value of attribute checked_value.
-
#constraints ⇒ Object
Returns the value of attribute constraints.
-
#location ⇒ Object
Returns the value of attribute location.
-
#reason ⇒ Object
Returns the value of attribute reason.
-
#validation ⇒ Object
Returns the value of attribute validation.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ValidationError
constructor
A new instance of ValidationError.
- #matches?(criteria = {}) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ ValidationError
Returns a new instance of ValidationError.
11 12 13 14 15 |
# File 'lib/errapi/validation_error.rb', line 11 def initialize = {} ATTRIBUTES.each do |attr| instance_variable_set "@#{attr}", [attr] if .key? attr end end |
Instance Attribute Details
#check_value ⇒ Object
Returns the value of attribute check_value.
5 6 7 |
# File 'lib/errapi/validation_error.rb', line 5 def check_value @check_value end |
#checked_value ⇒ Object
Returns the value of attribute checked_value.
6 7 8 |
# File 'lib/errapi/validation_error.rb', line 6 def checked_value @checked_value end |
#constraints ⇒ Object
Returns the value of attribute constraints.
8 9 10 |
# File 'lib/errapi/validation_error.rb', line 8 def constraints @constraints end |
#location ⇒ Object
Returns the value of attribute location.
9 10 11 |
# File 'lib/errapi/validation_error.rb', line 9 def location @location end |
#reason ⇒ Object
Returns the value of attribute reason.
4 5 6 |
# File 'lib/errapi/validation_error.rb', line 4 def reason @reason end |
#validation ⇒ Object
Returns the value of attribute validation.
7 8 9 |
# File 'lib/errapi/validation_error.rb', line 7 def validation @validation end |
Instance Method Details
#matches?(criteria = {}) ⇒ Boolean
17 18 19 20 21 |
# File 'lib/errapi/validation_error.rb', line 17 def matches? criteria = {} unknown_criteria = criteria.keys - ATTRIBUTES raise "Unknown error attributes: #{unknown_criteria.join(', ')}." if unknown_criteria.any? ATTRIBUTES.all?{ |attr| criterion_matches? criteria, attr } end |