Class: Apia::ManifestErrors
- Inherits:
-
Object
- Object
- Apia::ManifestErrors
- Defined in:
- lib/apia/manifest_errors.rb
Defined Under Namespace
Classes: Errors
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #add(object, code, message) ⇒ Object
- #empty? ⇒ Boolean
- #for(object) ⇒ Object
-
#initialize ⇒ ManifestErrors
constructor
A new instance of ManifestErrors.
- #raise_if_needed ⇒ Object
Constructor Details
#initialize ⇒ ManifestErrors
Returns a new instance of ManifestErrors.
10 11 12 |
# File 'lib/apia/manifest_errors.rb', line 10 def initialize @errors = {} end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
8 9 10 |
# File 'lib/apia/manifest_errors.rb', line 8 def errors @errors end |
Instance Method Details
#add(object, code, message) ⇒ Object
14 15 16 17 |
# File 'lib/apia/manifest_errors.rb', line 14 def add(object, code, ) @errors[object] ||= Errors.new @errors[object].add(code: code, message: ) end |
#empty? ⇒ Boolean
23 24 25 |
# File 'lib/apia/manifest_errors.rb', line 23 def empty? @errors.empty? end |
#for(object) ⇒ Object
19 20 21 |
# File 'lib/apia/manifest_errors.rb', line 19 def for(object) @errors[object] || Errors.new end |
#raise_if_needed ⇒ Object
27 28 29 30 31 |
# File 'lib/apia/manifest_errors.rb', line 27 def raise_if_needed return if empty? raise ManifestError, self end |