Sha256: 96b718509883b0cd8b135490f01c1da6a53afa1f42970743fb01fc950ff29ac1
Contents?: true
Size: 905 Bytes
Versions: 6
Compression:
Stored size: 905 Bytes
Contents
# -*- encoding : utf-8 -*- module SecondLevelCache module ActiveRecord module Associations module HasOneAssociation extend ActiveSupport::Concern included do class_eval do alias_method_chain :find_target, :second_level_cache end end def find_target_with_second_level_cache return find_target_without_second_level_cache unless association_class.second_level_cache_enabled? cache_record = association_class.fetch_by_uniq_key(owner[reflection.active_record_primary_key], reflection.foreign_key) return cache_record.tap{|record| set_inverse_instance(record)} if cache_record record = find_target_without_second_level_cache record.tap do |r| set_inverse_instance(r) r.write_second_level_cache end if record end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems