Exception: Recliner::DocumentInvalid

Inherits:
DocumentNotSaved show all
Defined in:
lib/recliner/validations.rb

Overview

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

begin
  complex_operation_that_calls_save!_internally
rescue Recliner::DocumentInvalid => invalid
  puts invalid.document.errors
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document) ⇒ DocumentInvalid

Returns a new instance of DocumentInvalid.



12
13
14
15
# File 'lib/recliner/validations.rb', line 12

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

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



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

def document
  @document
end