Class: Mongoid::Errors::StaleDocument

Inherits:
MongoidError
  • Object
show all
Defined in:
lib/mongoid/errors/stale_document.rb

Overview

Raised when trying to update a document that has been updated by another process.

Examples:

Create the error.

StaleDocument.new('update', document)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action, document) ⇒ StaleDocument

Returns a new instance of StaleDocument.



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

def initialize(action, document)
  @action = action
  @document = document

  super(
    translate(
      "stale_document.#{action}",
      { :klass => document.class.name }
    )
  )
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



13
14
15
# File 'lib/mongoid/errors/stale_document.rb', line 13

def action
  @action
end

#documentObject (readonly)

Returns the value of attribute document.



13
14
15
# File 'lib/mongoid/errors/stale_document.rb', line 13

def document
  @document
end