Module: ActiveRecord::NoTouching

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
activerecord/lib/active_record/no_touching.rb

Overview

Active Record No Touching

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActiveSupport::Concern

append_features, extended, included

Class Method Details

.applied_to?(klass) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


34
35
36
# File 'activerecord/lib/active_record/no_touching.rb', line 34

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

.apply_to(klass) ⇒ Object

:nodoc:



27
28
29
30
31
32
# File 'activerecord/lib/active_record/no_touching.rb', line 27

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

Instance Method Details

#no_touching?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'activerecord/lib/active_record/no_touching.rb', line 44

def no_touching?
  NoTouching.applied_to?(self.class)
end

#touchObject



48
49
50
# File 'activerecord/lib/active_record/no_touching.rb', line 48

def touch(*)
  super unless no_touching?
end