Class: Apia::ManifestErrors

Inherits:
Object
  • Object
show all
Defined in:
lib/apia/manifest_errors.rb

Defined Under Namespace

Classes: Errors

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeManifestErrors

Returns a new instance of ManifestErrors.



10
11
12
# File 'lib/apia/manifest_errors.rb', line 10

def initialize
  @errors = {}
end

Instance Attribute Details

#errorsObject (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, message)
  @errors[object] ||= Errors.new
  @errors[object].add(code: code, message: message)
end

#empty?Boolean

Returns:

  • (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_neededObject

Raises:



27
28
29
30
31
# File 'lib/apia/manifest_errors.rb', line 27

def raise_if_needed
  return if empty?

  raise ManifestError, self
end