Module: Perry::Middlewares::CacheRecords::Scopes
- Defined in:
- lib/perry/middlewares/cache_records/scopes.rb
Class Method Summary collapse
Class Method Details
.included(model) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/perry/middlewares/cache_records/scopes.rb', line 2 def self.included(model) model.class_eval do # Using the :fresh scope will skip the cache and execute query regardless of # whether a cached result is available or not. scope :fresh, (lambda do |*args| val = args.first.nil? ? true : args.first modifiers(:fresh => val) end) # Using the :reset_cache scope in a query will delete all entries from the # cache store before running the query. Whenever possible, you should use # the :fresh scope instead of :reset_cache. scope :reset_cache, modifiers(:reset_cache => true) end end |