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:



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/elastictastic/optimistic_locking.rb', line 65

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