Class: ActiveInteraction::Errors

Inherits:
ActiveModel::Errors
  • Object
show all
Defined in:
lib/active_interaction/errors.rb

Overview

An extension that provides the ability to merge other errors into itself.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#backtraceObject

Returns the value of attribute backtrace.



6
7
8
# File 'lib/active_interaction/errors.rb', line 6

def backtrace
  @backtrace
end

Instance Method Details

#local_attribute(attribute) ⇒ Object



28
29
30
# File 'lib/active_interaction/errors.rb', line 28

def local_attribute(attribute)
  attribute.to_s.sub(/\A([^.\[]*).*\z/, '\1').to_sym
end

#merge!(other) ⇒ Errors

Merge other errors into this one.

Parameters:

Returns:



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/active_interaction/errors.rb', line 13

def merge!(other)
  other.messages.each do |attribute, messages|
    messages.zip(other.details[attribute]) do |message, detail|
      if detailed_error?(detail)
        merge_detail!(attribute, detail, message)
      else
        merge_message!(attribute, detail, message)
      end
    end
  end

  self
end