module ActiveRecord::DelayTouching::ClassMethods

These get added as class methods to ActiveRecord::Base.

Public Instance Methods

delay_touching(&block) click to toggle source

Lets you batch up your `touch` calls for the duration of a block.

Examples

# Touches Person.first once, not twice, when the block exits.
ActiveRecord::Base.delay_touching do
  Person.first.touch
  Person.first.touch
end
# File lib/activerecord/delay_touching.rb, line 30
def delay_touching(&block)
  DelayTouching.call &block
end
delay_touching?() click to toggle source

Are we currently executing in a delay_touching block?

# File lib/activerecord/delay_touching.rb, line 35
def delay_touching?
  DelayTouching.state.nesting > 0
end