Sha256: 8aaf1860cf7637c37aefc8f66fe140949712a109a718f2c5420a1a4b5093ad3c
Contents?: true
Size: 915 Bytes
Versions: 5
Compression:
Stored size: 915 Bytes
Contents
# frozen_string_literal: true module SecondLevelCache module ActiveRecord module Associations module BelongsToAssociation def find_target return super unless klass.second_level_cache_enabled? return super if klass.default_scopes.present? || reflection.scope return super if reflection.active_record_primary_key.to_s != klass.primary_key cache_record = klass.read_second_level_cache(second_level_cache_key) if cache_record return cache_record.tap { |record| set_inverse_instance(record) } end record = super return nil unless record record.tap do |r| set_inverse_instance(r) r.write_second_level_cache end end private def second_level_cache_key owner[reflection.foreign_key] end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems