module ActiveRecord::NoTouching

def applied_to?(klass) # :nodoc:

:nodoc:
def applied_to?(klass) # :nodoc:
  klasses.any? { |k| k >= klass }
end

def apply_to(klass) # :nodoc:

:nodoc:
def apply_to(klass) # :nodoc:
  klasses.push(klass)
  yield
ensure
  klasses.pop
end

def klasses

def klasses
  ActiveSupport::IsolatedExecutionState[:active_record_no_touching_classes] ||= []
end

def no_touching?


end
Message.first.no_touching? # false
Project.first.no_touching? # true
Project.no_touching do

Returns +true+ if the class has +no_touching+ set, +false+ otherwise.
def no_touching?
  NoTouching.applied_to?(self.class)
end

def touch(*, **) # :nodoc:

:nodoc:
def touch(*, **) # :nodoc:
  super unless no_touching?
end

def touch_later(*) # :nodoc:

:nodoc:
def touch_later(*) # :nodoc:
  super unless no_touching?
end