Sha256: 4c27691e1a8eddab2d67d39c6757e5c4e44cf3cda3c10b529cc5b5a4b2e4194e

Contents?: true

Size: 1.46 KB

Versions: 7

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

require "second_level_cache/mixin"
require "second_level_cache/active_record/base"
require "second_level_cache/active_record/core"
require "second_level_cache/active_record/fetch_by_uniq_key"
require "second_level_cache/active_record/finder_methods"
require "second_level_cache/active_record/persistence"
require "second_level_cache/active_record/belongs_to_association"
require "second_level_cache/active_record/has_one_association"
require "second_level_cache/active_record/preloader"

# http://api.rubyonrails.org/classes/ActiveSupport/LazyLoadHooks.html
# ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base)
ActiveSupport.on_load(:active_record) do
  include SecondLevelCache::Mixin
  prepend SecondLevelCache::ActiveRecord::Base
  extend SecondLevelCache::ActiveRecord::FetchByUniqKey
  prepend SecondLevelCache::ActiveRecord::Persistence

  ActiveRecord::Associations::BelongsToAssociation.send(:prepend, SecondLevelCache::ActiveRecord::Associations::BelongsToAssociation)
  ActiveRecord::Associations::HasOneAssociation.send(:prepend, SecondLevelCache::ActiveRecord::Associations::HasOneAssociation)
  ActiveRecord::Relation.send(:prepend, SecondLevelCache::ActiveRecord::FinderMethods)
  # Rails 5.2 has removed ActiveRecord::Associations::Preloader::BelongsTo
  # https://github.com/rails/rails/pull/31079
  ActiveRecord::Associations::Preloader::Association.send(:prepend, SecondLevelCache::ActiveRecord::Associations::Preloader::BelongsTo)
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
second_level_cache-2.5.3 lib/second_level_cache/active_record.rb
second_level_cache-2.5.2 lib/second_level_cache/active_record.rb
second_level_cache-2.5.0 lib/second_level_cache/active_record.rb
second_level_cache-2.4.4 lib/second_level_cache/active_record.rb
second_level_cache-2.4.3 lib/second_level_cache/active_record.rb
second_level_cache-2.4.2 lib/second_level_cache/active_record.rb
second_level_cache-2.4.1 lib/second_level_cache/active_record.rb