Module: Elastictastic::OptimisticLocking

Extended by:
ActiveSupport::Concern
Defined in:
lib/elastictastic/optimistic_locking.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#try_update(scope, &block) ⇒ Object

:nodoc:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/elastictastic/optimistic_locking.rb', line 39

def try_update(scope, &block) #:nodoc:
  yield self
  update do |e|
    case e
    when nil # chill
    when Elastictastic::ServerError::VersionConflictEngineException,
      Elastictastic::ServerError::VersionConflictException # 0.19
      scope.update(id, &block)
    else
      raise e
    end
  end
rescue Elastictastic::CancelSave
  # Do Nothing
end