module Kakurenbo::MixinARLockingOptimistic

Public Class Methods

included(base_class) click to toggle source

Override methods.

# File lib/kakurenbo/mixin_ar_locking_optimistic.rb, line 4
def self.included(base_class)
  base_class.class_eval do
   def destroy_row(options = {:hard => false})
      affected_rows = super(options)

      if locking_enabled? && affected_rows != 1
        raise ActiveRecord::StaleObjectError.new(self, "destroy")
      end

      affected_rows
    end
  end
end

Public Instance Methods

destroy_row(options = {:hard => false}) click to toggle source
Calls superclass method
# File lib/kakurenbo/mixin_ar_locking_optimistic.rb, line 6
def destroy_row(options = {:hard => false})
   affected_rows = super(options)

   if locking_enabled? && affected_rows != 1
     raise ActiveRecord::StaleObjectError.new(self, "destroy")
   end

   affected_rows
 end