Exception: AntMapper::ObjectInvalid

Inherits:
AntMapperError show all
Defined in:
lib/ant_mapper/validations.rb

Overview

Raised by save! and create! when the object is invalid. Use the object method to retrieve the object which did not validate.

begin
  complex_operation_that_calls_save!_internally
rescue AntMapper::ObjectInvalid => invalid
  puts invalid.record.errors
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ ObjectInvalid

Returns a new instance of ObjectInvalid.



11
12
13
14
# File 'lib/ant_mapper/validations.rb', line 11

def initialize(object)
  @object = object
  super("Validation failed: #{@object.errors.full_messages.join(", ")}")
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



10
11
12
# File 'lib/ant_mapper/validations.rb', line 10

def object
  @object
end