Class: ActionController::Caching::Sweeper

Inherits:
ActiveRecord::Observer show all
Defined in:
lib/rails/observers/action_controller/caching/sweeping.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ActiveModel::Observer

observe, observed_class, #observed_class_inherited, #observed_classes, observed_classes, #update

Constructor Details

#initialize(*args) ⇒ Sweeper

Returns a new instance of Sweeper.



57
58
59
60
# File 'lib/rails/observers/action_controller/caching/sweeping.rb', line 57

def initialize(*args)
  super
  @controller = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *arguments, &block) ⇒ Object (private)



106
107
108
109
# File 'lib/rails/observers/action_controller/caching/sweeping.rb', line 106

def method_missing(method, *arguments, &block)
  return super unless @controller
  @controller.__send__(method, *arguments, &block)
end

Instance Attribute Details

#controllerObject

Returns the value of attribute controller.



55
56
57
# File 'lib/rails/observers/action_controller/caching/sweeping.rb', line 55

def controller
  @controller
end

Instance Method Details

#after(controller) ⇒ Object



68
69
70
71
# File 'lib/rails/observers/action_controller/caching/sweeping.rb', line 68

def after(controller)
  self.controller = controller
  callback(:after) if controller.perform_caching
end

#around(controller) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/rails/observers/action_controller/caching/sweeping.rb', line 73

def around(controller)
  before(controller)
  yield
  after(controller)
ensure
  clean_up
end

#before(controller) ⇒ Object



62
63
64
65
66
# File 'lib/rails/observers/action_controller/caching/sweeping.rb', line 62

def before(controller)
  self.controller = controller
  callback(:before) if controller.perform_caching
  true # before method from sweeper should always return true
end