Sha256: c7c02ccdbbfa81470aa21ddb8a711f2642c39007a4add919833050a57c4596d2

Contents?: true

Size: 682 Bytes

Versions: 2

Compression:

Stored size: 682 Bytes

Contents

require 'cachers/base'
require 'cachers/concern'
require 'cachers/railtie'

module Cachers
  class << self

    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|
            puts "Running #{action} on #{model.name} ##{record.id}"
            record.send action
          end
        end
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cachers-0.1.1 lib/cachers.rb
cachers-0.0.1 lib/cachers.rb