Module: DigestParserValidator
- Included in:
- DigestEmail::DigestParser
- Defined in:
- lib/digest_email/digest_parser_validator.rb
Instance Method Summary collapse
-
#valid_index?(item, index) ⇒ Boolean
Invalidates index if missing or empty, taking advantage of lazy eval.
-
#validate_index(item, index) ⇒ Object
Validate an index for given hash.
-
#validate_indices(item, indices) ⇒ Object
Validates multiple indices for given hash.
Instance Method Details
#valid_index?(item, index) ⇒ Boolean
Invalidates index if missing or empty, taking advantage of lazy eval
4 5 6 |
# File 'lib/digest_email/digest_parser_validator.rb', line 4 def valid_index?(item, index) item.has_key?(index) and !item[index].nil? and !item[index].empty? end |
#validate_index(item, index) ⇒ Object
Validate an index for given hash
9 10 11 12 13 |
# File 'lib/digest_email/digest_parser_validator.rb', line 9 def validate_index(item, index) unless valid_index?(item, index) raise "Missing digest field #{index.capitalize}" end end |
#validate_indices(item, indices) ⇒ Object
Validates multiple indices for given hash
16 17 18 19 20 |
# File 'lib/digest_email/digest_parser_validator.rb', line 16 def validate_indices(item, indices) indices.each do |index| validate_index(item, index) end end |