Class: ElectionBuddy::Validation::ListErrors
- Inherits:
-
Object
- Object
- ElectionBuddy::Validation::ListErrors
- Includes:
- Enumerable
- Defined in:
- lib/election_buddy/entities/validation/list_errors.rb
Overview
Represents a collection of voter list validation errors
Instance Attribute Summary collapse
-
#total ⇒ Integer
readonly
Total number of validation errors.
Instance Method Summary collapse
- #collection ⇒ Object private
-
#each(&block) ⇒ Enumerator
Iterates through each list error.
-
#empty? ⇒ Boolean
Checks if there are any list errors.
-
#initialize(response) ⇒ ListErrors
constructor
A new instance of ListErrors.
Constructor Details
#initialize(response) ⇒ ListErrors
Returns a new instance of ListErrors.
19 20 21 22 |
# File 'lib/election_buddy/entities/validation/list_errors.rb', line 19 def initialize(response) @list_errors = response["voter_list_errors"] @total = response["meta"]["total"] end |
Instance Attribute Details
#total ⇒ Integer (readonly)
Returns Total number of validation errors.
16 17 18 |
# File 'lib/election_buddy/entities/validation/list_errors.rb', line 16 def total @total end |
Instance Method Details
#collection ⇒ Object (private)
40 41 42 43 44 |
# File 'lib/election_buddy/entities/validation/list_errors.rb', line 40 def collection @collection ||= @list_errors .map { |category, | { category => } } .map { |list_error| ListError.new(list_error) } end |
#each(&block) ⇒ Enumerator
Iterates through each list error
27 28 29 |
# File 'lib/election_buddy/entities/validation/list_errors.rb', line 27 def each(&block) collection.each(&block) end |
#empty? ⇒ Boolean
Checks if there are any list errors
34 35 36 |
# File 'lib/election_buddy/entities/validation/list_errors.rb', line 34 def empty? collection.empty? end |