class ActionInteractor::Errors

Action Interactor Errors

Provides a Hash like object to Action Interactors execution errors.

Attributes

errors[R]

Public Class Methods

new(*) click to toggle source
# File lib/action_interactor/errors.rb, line 16
def initialize(*)
  @errors = {}
end

Public Instance Methods

add(attribute, error) click to toggle source

Add error to the errors hash.

# File lib/action_interactor/errors.rb, line 21
def add(attribute, error)
  errors[attribute.to_sym] = error
end
delete(key) click to toggle source

Delete a error for key.

# File lib/action_interactor/errors.rb, line 26
def delete(key)
  attribute = key.to_sym
  errors.delete(attribute)
end
each() { |attribute, errors| ... } click to toggle source

Iterates through each error key, value pair in the errors hash.

# File lib/action_interactor/errors.rb, line 32
def each
  errors.each_key do |attribute|
    yield attribute, errors[attribute]
  end
end
messages() click to toggle source

Returns array containing error messages.

# File lib/action_interactor/errors.rb, line 44
def messages
  errors.map do |attribute, error|
    "#{attribute} #{error}"
  end
end
to_hash() click to toggle source

Convert errors to hash.

# File lib/action_interactor/errors.rb, line 39
def to_hash
  errors
end