123456789_123456789_123456789_123456789_123456789_

Module: ActiveRecord::NoTouching

Relationships & Source Files
Namespace Children
Modules:
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Defined in: activerecord/lib/active_record/no_touching.rb

Class Method Summary

::ActiveSupport::Concern - Extended

class_methods

Define class methods from given block.

included

Evaluate given block in context of base class, so that you can write class macros here.

prepended

Evaluate given block in context of base class, so that you can write class macros here.

append_features, prepend_features

Instance Attribute Summary

Instance Method Summary

Class Method Details

.applied_to?(klass) ⇒ Boolean

This method is for internal use only.
[ GitHub ]

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

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

.apply_to(klass)

This method is for internal use only.
[ GitHub ]

  
# File 'activerecord/lib/active_record/no_touching.rb', line 29

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

.klasses (private)

[ GitHub ]

  
# File 'activerecord/lib/active_record/no_touching.rb', line 41

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

Instance Attribute Details

#no_touching?Boolean (readonly)

Returns true if the class has no_touching set, false otherwise.

Project.no_touching do
  Project.first.no_touching? # true
  Message.first.no_touching? # false
end
[ GitHub ]

  
# File 'activerecord/lib/active_record/no_touching.rb', line 53

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

Instance Method Details

#touch

This method is for internal use only.
[ GitHub ]

  
# File 'activerecord/lib/active_record/no_touching.rb', line 61

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

#touch_later

This method is for internal use only.
[ GitHub ]

  
# File 'activerecord/lib/active_record/no_touching.rb', line 57

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