Module: Scryer::QueryWatcher::AccessTracking

Defined in:
lib/scryer/query_watcher.rb

Overview

Prepended onto both association classes. reader is the method the generated association method (post.comments) actually calls (see ActiveRecord::Associations::Builder::Association) — unlike load_target, it fires on every access, preloaded or not, which is exactly what "was this ever read" needs.

Instance Method Summary collapse

Instance Method Details

#readerObject



227
228
229
230
231
# File 'lib/scryer/query_watcher.rb', line 227

def reader
  scope = Scryer::QueryWatcher.current_scope
  scope&.record_access(owner.class.name, reflection.name.to_s)
  super
end