4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/active_touch/touch_job.rb', line 4
def perform(record, association, after_touch, is_async = ActiveTouch.configuration.async)
associated = association == 'self' ? record : record.send(association)
if associated.is_a? ActiveRecord::Base
associated.update_columns(ActiveTouch.timestamp_attribute => record.updated_at) unless ActiveTouch.timestamp_attribute.nil?
associated.send(after_touch) unless after_touch.blank?
elsif !associated.nil? && !associated.empty?
associated.update_all(ActiveTouch.timestamp_attribute => record.updated_at) unless ActiveTouch.timestamp_attribute.nil?
associated.each { |associate| associate.send(after_touch) } unless after_touch.blank?
end
end
|