Class: Cavalry::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/cavalry/error.rb

Instance Method Summary collapse

Constructor Details

#initialize(record) ⇒ Error

Returns a new instance of Error.



5
6
7
8
# File 'lib/cavalry/error.rb', line 5

def initialize(record)
  @record = record
  dump
end

Instance Method Details

#dumpObject



10
11
12
13
14
15
# File 'lib/cavalry/error.rb', line 10

def dump
  { record: @record.class.name }.tap do |h|
    h.merge!(attributes: @record.attributes) if @record.respond_to?(:attributes)
    h.merge!(errors: errors.to_hash)
  end
end