Module: ActiveRemote::Serialization

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/active_remote/serialization.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#add_errors(errors) ⇒ Object

Add the given errors to our internal errors list

Examples

response = remote_call(:action_that_returns_errors, { :stuff => 'foo' })

add_errors(response.errors)


35
36
37
38
39
40
41
42
43
44
45
# File 'lib/active_remote/serialization.rb', line 35

def add_errors(errors)
  errors.each do |error|
    if error.respond_to?(:message)
      self.errors.add(error.field, error.message)
    elsif error.respond_to?(:messages)
      error.messages.each do |message|
        self.errors.add(error.field, message)
      end
    end
  end
end