Class: Cliqr::ValidationErrors Private
- Inherits:
-
Object
- Object
- Cliqr::ValidationErrors
- Defined in:
- lib/cliqr/validation_errors.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A wrapper of validation errors which provides helpful methods for accessing it
Instance Attribute Summary collapse
-
#errors ⇒ Array<String]
private
List of all error messages.
Instance Method Summary collapse
-
#add(error_message) ⇒ Array
private
Add a new error message.
-
#each(&block) ⇒ Set<String>
private
Iterate over each error message.
-
#empty? ⇒ Boolean
private
Check if there are error or not.
-
#initialize ⇒ ValidationErrors
constructor
private
Create a new instance of the validation error wrapper.
-
#merge(other) ⇒ Cliqr::Validation::Errors
private
Merge the list of errors from another.
-
#to_s ⇒ String
private
Convert list of errors to a string representation.
Constructor Details
#initialize ⇒ ValidationErrors
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new instance of the validation error wrapper
16 17 18 |
# File 'lib/cliqr/validation_errors.rb', line 16 def initialize @errors = Set.new [] end |
Instance Attribute Details
#errors ⇒ Array<String]
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
List of all error messages
13 14 15 |
# File 'lib/cliqr/validation_errors.rb', line 13 def errors @errors end |
Instance Method Details
#add(error_message) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Add a new error message
25 26 27 |
# File 'lib/cliqr/validation_errors.rb', line 25 def add() @errors.add() end |
#each(&block) ⇒ Set<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Iterate over each error message
57 58 59 |
# File 'lib/cliqr/validation_errors.rb', line 57 def each(&block) @errors.each(&block) end |
#empty? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if there are error or not
32 33 34 |
# File 'lib/cliqr/validation_errors.rb', line 32 def empty? @errors.empty? end |
#merge(other) ⇒ Cliqr::Validation::Errors
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Merge the list of errors from another
48 49 50 |
# File 'lib/cliqr/validation_errors.rb', line 48 def merge(other) @errors = @errors.union(other.errors) end |
#to_s ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Convert list of errors to a string representation
39 40 41 |
# File 'lib/cliqr/validation_errors.rb', line 39 def to_s @errors.to_a.join(', ') end |