diff options
author | Ryan Garver <ragarver@gmail.com> | 2012-10-02 10:37:27 -0700 |
---|---|---|
committer | Ryan Garver <ragarver@gmail.com> | 2012-10-02 10:37:27 -0700 |
commit | 4cb50a3f571234b1202f9a0dffe39b445ecf807d (patch) | |
tree | 13780082c3974bc480cf35722cabf8788beed3ab /actionpack/lib/action_controller/caching/sweeping.rb | |
parent | 3fdb7126110caad3f3db4c2b44ffc365b51c34eb (diff) | |
parent | df08271f9c044b7614d70baf4b818f1a79f4a6e1 (diff) | |
download | rails-4cb50a3f571234b1202f9a0dffe39b445ecf807d.tar.gz rails-4cb50a3f571234b1202f9a0dffe39b445ecf807d.tar.bz2 rails-4cb50a3f571234b1202f9a0dffe39b445ecf807d.zip |
Merge branch 'master' into feature/public-fragment_name_with_digest
Diffstat (limited to 'actionpack/lib/action_controller/caching/sweeping.rb')
-rw-r--r-- | actionpack/lib/action_controller/caching/sweeping.rb | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/actionpack/lib/action_controller/caching/sweeping.rb b/actionpack/lib/action_controller/caching/sweeping.rb index 271d5f06b8..317ac74b40 100644 --- a/actionpack/lib/action_controller/caching/sweeping.rb +++ b/actionpack/lib/action_controller/caching/sweeping.rb @@ -1,38 +1,41 @@ -module ActionController #:nodoc: +module ActionController module Caching - # Sweepers are the terminators of the caching world and responsible for expiring caches when Active Record objects change. - # They do this by being half-observers, half-filters and implementing callbacks for both roles. A Sweeper example: + # Sweepers are the terminators of the caching world and responsible for expiring + # caches when Active Record objects change. They do this by being half-observers, + # half-filters and implementing callbacks for both roles. # # class ListSweeper < ActionController::Caching::Sweeper # observe List, Item # # def after_save(record) # list = record.is_a?(List) ? record : record.list - # expire_page(:controller => "lists", :action => %w( show public feed ), :id => list.id) - # expire_action(:controller => "lists", :action => "all") - # list.shares.each { |share| expire_page(:controller => "lists", :action => "show", :id => share.url_key) } + # expire_page(controller: 'lists', action: %w( show public feed ), id: list.id) + # expire_action(controller: 'lists', action: 'all') + # list.shares.each { |share| expire_page(controller: 'lists', action: 'show', id: share.url_key) } # end # end # - # The sweeper is assigned in the controllers that wish to have its job performed using the <tt>cache_sweeper</tt> class method: + # The sweeper is assigned in the controllers that wish to have its job performed using + # the +cache_sweeper+ class method: # # class ListsController < ApplicationController # caches_action :index, :show, :public, :feed - # cache_sweeper :list_sweeper, :only => [ :edit, :destroy, :share ] + # cache_sweeper :list_sweeper, only: [ :edit, :destroy, :share ] # end # # In the example above, four actions are cached and three actions are responsible for expiring those caches. # - # You can also name an explicit class in the declaration of a sweeper, which is needed if the sweeper is in a module: + # You can also name an explicit class in the declaration of a sweeper, which is needed + # if the sweeper is in a module: # # class ListsController < ApplicationController # caches_action :index, :show, :public, :feed - # cache_sweeper OpenBar::Sweeper, :only => [ :edit, :destroy, :share ] + # cache_sweeper OpenBar::Sweeper, only: [ :edit, :destroy, :share ] # end module Sweeping extend ActiveSupport::Concern - module ClassMethods #:nodoc: + module ClassMethods # :nodoc: def cache_sweeper(*sweepers) configuration = sweepers.extract_options! @@ -51,7 +54,7 @@ module ActionController #:nodoc: end if defined?(ActiveRecord) and defined?(ActiveRecord::Observer) - class Sweeper < ActiveRecord::Observer #:nodoc: + class Sweeper < ActiveRecord::Observer # :nodoc: attr_accessor :controller def initialize(*args) |