Sha256: 1f9722de246fe8e268f02172f772bf73fa865f09dc79041e4f560733230715b1

Contents?: true

Size: 897 Bytes

Versions: 1

Compression:

Stored size: 897 Bytes

Contents

require 'cachers/extensions/active_record/base'
require 'cachers/dsl'
require 'cachers/base'
require 'cachers/delegation'
require 'cachers/concern'
require 'cachers/railtie'
require 'cachers/version'

module Cachers
  class << self

    def redis
      @redis ||= begin
        require 'redis'
        Redis.new YAML.load_file("#{Rails.root}/config/redis.yml")[Rails.env]
      end
    end

    def models
      if Rails.configuration.cache_classes == false
        Rails.application.eager_load!
      end
      ActiveRecord::Base.descendants.select do |model|
        model.included_modules.include?(Cachers::Concern) && model.descendants.none?
      end
    end

    %i(cache uncache recache).each do |action|
      define_method action do
        models.each do |model|
          model.find_each do |record|
            record.send action
          end
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cachers-5.1.2 lib/cachers.rb