cache_keeper 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/Gemfile.lock +1 -1
 - data/app/models/cache_keeper/cached_method.rb +1 -1
 - data/lib/cache_keeper/caching.rb +14 -12
 - data/lib/cache_keeper/configuration.rb +15 -13
 - data/lib/cache_keeper/engine.rb +23 -14
 - data/lib/cache_keeper/manager.rb +29 -27
 - data/lib/cache_keeper/replace_method.rb +36 -34
 - data/lib/cache_keeper/version.rb +1 -1
 - data/lib/cache_keeper.rb +7 -5
 - data/test/manager_test.rb +3 -0
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 3bef46cb308534d247ff50712366a7548864043aa0bf6cd4a75ccd2edeed1fee
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 4c6375f02da64d4d60c38c6a7e2839c0e1d4084271011bc4a8fcd5d83a65caaa
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 27a68b7c00a743092d3b6e317df3c38edae644be451c0760c186b66e648ecca7acccb5b4540369b3885f7e6a9fb9d5c5723e4fcd4f8877d6fc126d6b4853cc0a
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 8a9fea0f3c9b654c530e6519bf6ccdbc0fabe7ff0ccd2e33d3efed9dc3272437135afe7ea07a98c86b9e927f01e3cb7c139d92a78828372354a6181ef25b057d
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/lib/cache_keeper/caching.rb
    CHANGED
    
    | 
         @@ -1,20 +1,22 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module CacheKeeper 
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
      
 1 
     | 
    
         
            +
            module CacheKeeper
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Caching
         
     | 
| 
      
 3 
     | 
    
         
            +
                extend ActiveSupport::Concern
         
     | 
| 
       3 
4 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
                included do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  def self.caches(*method_names, **options)
         
     | 
| 
      
 7 
     | 
    
         
            +
                    method_names.each do |method_name|
         
     | 
| 
      
 8 
     | 
    
         
            +
                      CacheKeeper.manager.handle self, method_name, options
         
     | 
| 
       8 
9 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 10 
     | 
    
         
            +
                      # If the method is already defined, we need to hook it
         
     | 
| 
      
 11 
     | 
    
         
            +
                      method_added method_name
         
     | 
| 
      
 12 
     | 
    
         
            +
                    end
         
     | 
| 
       11 
13 
     | 
    
         
             
                  end
         
     | 
| 
       12 
     | 
    
         
            -
                end
         
     | 
| 
       13 
14 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
                  def self.method_added(method_name)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    super
         
     | 
| 
       16 
17 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
                    CacheKeeper.manager.activate_if_handling self, method_name
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
       18 
20 
     | 
    
         
             
                end
         
     | 
| 
       19 
21 
     | 
    
         
             
              end
         
     | 
| 
       20 
22 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,20 +1,22 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            module CacheKeeper
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Configuration
         
     | 
| 
      
 3 
     | 
    
         
            +
                DEFAULT_MUST_REVALIDATE = false
         
     | 
| 
      
 4 
     | 
    
         
            +
                DEFAULT_QUEUES = {}
         
     | 
| 
       4 
5 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 6 
     | 
    
         
            +
                def must_revalidate
         
     | 
| 
      
 7 
     | 
    
         
            +
                  return rails_config[:must_revalidate] unless rails_config[:must_revalidate].nil?
         
     | 
| 
       7 
8 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 9 
     | 
    
         
            +
                  DEFAULT_MUST_REVALIDATE
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
       10 
11 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 12 
     | 
    
         
            +
                def queues
         
     | 
| 
      
 13 
     | 
    
         
            +
                  rails_config[:queues] || DEFAULT_QUEUES
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 16 
     | 
    
         
            +
                private
         
     | 
| 
       16 
17 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
                def rails_config
         
     | 
| 
      
 19 
     | 
    
         
            +
                  Rails.application.config.cache_keeper
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
       19 
21 
     | 
    
         
             
              end
         
     | 
| 
       20 
22 
     | 
    
         
             
            end
         
     | 
    
        data/lib/cache_keeper/engine.rb
    CHANGED
    
    | 
         @@ -1,22 +1,31 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
      
 1 
     | 
    
         
            +
            module CacheKeeper
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Engine < ::Rails::Engine
         
     | 
| 
      
 3 
     | 
    
         
            +
                isolate_namespace CacheKeeper
         
     | 
| 
       3 
4 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
                config.cache_keeper = ActiveSupport::OrderedOptions.new
         
     | 
| 
      
 6 
     | 
    
         
            +
                config.cache_keeper.queues = ActiveSupport::InheritableOptions.new
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                config. 
     | 
| 
       9 
     | 
    
         
            -
                   
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
                config.eager_load_namespaces << CacheKeeper
         
     | 
| 
      
 9 
     | 
    
         
            +
                config.autoload_once_paths = %W(
         
     | 
| 
      
 10 
     | 
    
         
            +
                  #{root}/app/jobs
         
     | 
| 
      
 11 
     | 
    
         
            +
                  #{root}/app/models
         
     | 
| 
      
 12 
     | 
    
         
            +
                  #{root}/app/serializers
         
     | 
| 
      
 13 
     | 
    
         
            +
                )
         
     | 
| 
       12 
14 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
                initializer "cache_keeper.active_job_serializer" do |app|
         
     | 
| 
      
 16 
     | 
    
         
            +
                  config.to_prepare do
         
     | 
| 
      
 17 
     | 
    
         
            +
                    Rails.application.config.active_job.custom_serializers << CacheKeeper::CachedMethodSerializer
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
       16 
19 
     | 
    
         
             
                end
         
     | 
| 
       17 
20 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
                 
     | 
| 
       19 
     | 
    
         
            -
                   
     | 
| 
      
 21 
     | 
    
         
            +
                initializer "cache_keeper.caching_methods" do |app|
         
     | 
| 
      
 22 
     | 
    
         
            +
                  ActiveSupport.on_load :action_controller do
         
     | 
| 
      
 23 
     | 
    
         
            +
                    ActionController::Base.send :include, CacheKeeper::Caching
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  ActiveSupport.on_load :active_record do
         
     | 
| 
      
 27 
     | 
    
         
            +
                    include CacheKeeper::Caching
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
       20 
29 
     | 
    
         
             
                end
         
     | 
| 
       21 
30 
     | 
    
         
             
              end
         
     | 
| 
       22 
31 
     | 
    
         
             
            end
         
     | 
    
        data/lib/cache_keeper/manager.rb
    CHANGED
    
    | 
         @@ -1,42 +1,44 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
      
 1 
     | 
    
         
            +
            module CacheKeeper
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Manager
         
     | 
| 
      
 3 
     | 
    
         
            +
                attr_accessor :cached_methods
         
     | 
| 
       3 
4 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 6 
     | 
    
         
            +
                  self.cached_methods = []
         
     | 
| 
      
 7 
     | 
    
         
            +
                end
         
     | 
| 
       7 
8 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 9 
     | 
    
         
            +
                def find(klass, method_name)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  cached_methods.find do |cached_method|
         
     | 
| 
      
 11 
     | 
    
         
            +
                    cached_method.klass == klass && cached_method.method_name == method_name
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
       11 
13 
     | 
    
         
             
                end
         
     | 
| 
       12 
     | 
    
         
            -
              end
         
     | 
| 
       13 
14 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
                def handled?(klass, method_name)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  find(klass, method_name).present?
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
       17 
18 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 19 
     | 
    
         
            +
                def handle(klass, method_name, options)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  CacheKeeper::CachedMethod.new(klass, method_name, options).tap do |cached_method|
         
     | 
| 
      
 21 
     | 
    
         
            +
                    cached_methods << cached_method
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
       21 
23 
     | 
    
         
             
                end
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
24 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
                def activate_if_handling(klass, method_name)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  cached_method = find(klass, method_name) or return
         
     | 
| 
       26 
27 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
      
 28 
     | 
    
         
            +
                  return unless requires_activation?(cached_method)
         
     | 
| 
       28 
29 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
      
 30 
     | 
    
         
            +
                  CacheKeeper::ReplaceMethod.replace(cached_method) do
         
     | 
| 
      
 31 
     | 
    
         
            +
                    cached_method.call(self)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
       31 
33 
     | 
    
         
             
                end
         
     | 
| 
       32 
     | 
    
         
            -
              end
         
     | 
| 
       33 
34 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 35 
     | 
    
         
            +
                private
         
     | 
| 
       35 
36 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
      
 37 
     | 
    
         
            +
                def requires_activation?(cached_method)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  return false if cached_method.klass.instance_methods.exclude?(cached_method.method_name) && cached_method.klass.private_instance_methods.exclude?(cached_method.method_name)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  return false if cached_method.klass.private_instance_methods.include?(cached_method.alias_for_original_method)
         
     | 
| 
       39 
40 
     | 
    
         | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
      
 41 
     | 
    
         
            +
                  true
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
       41 
43 
     | 
    
         
             
              end
         
     | 
| 
       42 
44 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,46 +1,48 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Based on https://github.com/Shopify/sorbet/blob/master/gems/sorbet-runtime/lib/types/private/class_utils.rb
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
              class  
     | 
| 
       4 
     | 
    
         
            -
                 
     | 
| 
       5 
     | 
    
         
            -
                   
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
      
 2 
     | 
    
         
            +
            module CacheKeeper
         
     | 
| 
      
 3 
     | 
    
         
            +
              class ReplaceMethod
         
     | 
| 
      
 4 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 5 
     | 
    
         
            +
                  def replace(cached_method, &block)
         
     | 
| 
      
 6 
     | 
    
         
            +
                    klass = cached_method.klass
         
     | 
| 
      
 7 
     | 
    
         
            +
                    method_name = cached_method.method_name
         
     | 
| 
      
 8 
     | 
    
         
            +
                    alias_for_original_method = cached_method.alias_for_original_method
         
     | 
| 
      
 9 
     | 
    
         
            +
                    original_visibility = visibility_method_name(klass, method_name)
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
                    define_method_with_visibility klass, method_name, alias_for_original_method, original_visibility, &block
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
       12 
13 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 14 
     | 
    
         
            +
                  private
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
      
 16 
     | 
    
         
            +
                  # `name` must be an instance method (for class methods, pass in mod.singleton_class)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  def visibility_method_name(klass, method_name)
         
     | 
| 
      
 18 
     | 
    
         
            +
                    if klass.public_method_defined? method_name
         
     | 
| 
      
 19 
     | 
    
         
            +
                      :public
         
     | 
| 
      
 20 
     | 
    
         
            +
                    elsif klass.protected_method_defined? method_name
         
     | 
| 
      
 21 
     | 
    
         
            +
                      :protected
         
     | 
| 
      
 22 
     | 
    
         
            +
                    elsif klass.private_method_defined? method_name
         
     | 
| 
      
 23 
     | 
    
         
            +
                      :private
         
     | 
| 
      
 24 
     | 
    
         
            +
                    else
         
     | 
| 
      
 25 
     | 
    
         
            +
                      raise NameError.new("undefined method `#{method_name}` for `#{klass}`")
         
     | 
| 
      
 26 
     | 
    
         
            +
                    end
         
     | 
| 
       25 
27 
     | 
    
         
             
                  end
         
     | 
| 
       26 
     | 
    
         
            -
                end
         
     | 
| 
       27 
28 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 29 
     | 
    
         
            +
                  def define_method_with_visibility(klass, method_name, alias_for_original_method, visibility, &block)
         
     | 
| 
      
 30 
     | 
    
         
            +
                    klass.module_exec do
         
     | 
| 
      
 31 
     | 
    
         
            +
                      alias_method alias_for_original_method, method_name
         
     | 
| 
      
 32 
     | 
    
         
            +
                      private alias_for_original_method
         
     | 
| 
       32 
33 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
      
 34 
     | 
    
         
            +
                      # Start a visibility (public/protected/private) region, so that
         
     | 
| 
      
 35 
     | 
    
         
            +
                      # all of the method redefinitions happen with the right visibility
         
     | 
| 
      
 36 
     | 
    
         
            +
                      # from the beginning. This ensures that any other code that is
         
     | 
| 
      
 37 
     | 
    
         
            +
                      # triggered by `method_added`, sees the redefined method with the
         
     | 
| 
      
 38 
     | 
    
         
            +
                      # right visibility.
         
     | 
| 
      
 39 
     | 
    
         
            +
                      send visibility
         
     | 
| 
       39 
40 
     | 
    
         | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
      
 41 
     | 
    
         
            +
                      define_method method_name, &block
         
     | 
| 
       41 
42 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
      
 43 
     | 
    
         
            +
                      if block && block.arity < 0 && respond_to?(:ruby2_keywords, true)
         
     | 
| 
      
 44 
     | 
    
         
            +
                        ruby2_keywords method_name
         
     | 
| 
      
 45 
     | 
    
         
            +
                      end
         
     | 
| 
       44 
46 
     | 
    
         
             
                    end
         
     | 
| 
       45 
47 
     | 
    
         
             
                  end
         
     | 
| 
       46 
48 
     | 
    
         
             
                end
         
     | 
    
        data/lib/cache_keeper/version.rb
    CHANGED
    
    
    
        data/lib/cache_keeper.rb
    CHANGED
    
    | 
         @@ -1,11 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "cache_keeper/engine"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            require "cache_keeper/caching"
         
     | 
| 
       4 
     | 
    
         
            -
            require "cache_keeper/configuration"
         
     | 
| 
       5 
     | 
    
         
            -
            require "cache_keeper/manager"
         
     | 
| 
       6 
     | 
    
         
            -
            require "cache_keeper/replace_method"
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
3 
     | 
    
         
             
            module CacheKeeper
         
     | 
| 
      
 4 
     | 
    
         
            +
              extend ActiveSupport::Autoload
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              autoload :Caching
         
     | 
| 
      
 7 
     | 
    
         
            +
              autoload :Configuration
         
     | 
| 
      
 8 
     | 
    
         
            +
              autoload :Manager
         
     | 
| 
      
 9 
     | 
    
         
            +
              autoload :ReplaceMethod
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
       9 
11 
     | 
    
         
             
              mattr_accessor :logger, default: ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new($stdout))
         
     | 
| 
       10 
12 
     | 
    
         | 
| 
       11 
13 
     | 
    
         
             
              mattr_accessor :configuration, default: CacheKeeper::Configuration.new
         
     | 
    
        data/test/manager_test.rb
    CHANGED
    
    | 
         @@ -2,6 +2,9 @@ require "test_helper" 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            class CacheKeeper::ManagerTest < ActiveSupport::TestCase
         
     | 
| 
       4 
4 
     | 
    
         
             
              test "keeps record of the cached methods" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                # Load model
         
     | 
| 
      
 6 
     | 
    
         
            +
                Recording
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       5 
8 
     | 
    
         
             
                assert_equal 1, CacheKeeper.manager.cached_methods.count
         
     | 
| 
       6 
9 
     | 
    
         
             
                assert_equal :slow_method, CacheKeeper.manager.cached_methods.first.method_name
         
     | 
| 
       7 
10 
     | 
    
         
             
              end
         
     |