Class: ActiveRecordCache::DefaultsHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record_cache/defaults_handler.rb

Overview

Rack handler that sets the default for classes if they will use the cache for queries.

Instance Method Summary collapse

Constructor Details

#initialize(app, options) ⇒ DefaultsHandler

Returns a new instance of DefaultsHandler.



4
5
6
7
# File 'lib/active_record_cache/defaults_handler.rb', line 4

def initialize(app, options)
  @app = app
  @options = options
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
# File 'lib/active_record_cache/defaults_handler.rb', line 9

def call(env)
  ActiveRecordCache.enable_by_default_on(@options) do
    @app.call(env)
  end
end