あすなろとダブルポストです。+最後の感想ちょこっと変更しました。
まとめ
Ctonroller
after_cont
oroller_ac tion
before_contoroller_a ction
ex. after_blog
→ BlogContro
流れをわかるためのもがき
ぐぐってヒントを見つける。
[Rails][cache] Sweeper
http://d.hatena.ne.j p/meritdem erit/20070 607/p2
なんとなくはわかるけど、やっぱりよくわからないのでソースを見ることにする。Rails Referenceで検索する。右上にファイルの場所があるので確認。
vendor/rails/actionp ack/lib/ac tion_contr oller/cach ing.rb
http://api.rubyonrai ls.org/cla sses/Actio nControlle r/Caching/ Sweeping.h tml ソースを読む:cache_swe
eperキーワード 1 def cache_swee
per(*sweepers) 2 return unless perform_ca ching 3 configurat ion = sweepers.extract_op tions! 4 sweepers.each do |sweeper| 5 ActiveReco rd::Base.observers << sweeper if defined?(ActiveReco rd) and defined?(ActiveReco rd::Base) 6 sweeper_in stance = Object.const_get(Inflector.classify(sweeper)).instance 7 if sweeper_in stance.is_a?(Sweeper) 8 around_fil ter(sweeper_in stance, :only => configurat ion[:only]) 9 else 10 after_filt er(sweeper_in stance, :only => configurat ion[:only]) 11 end 12 end 13 end ソースを読む:after処理のエントリポイント
1 def after(controller
) 2 callback(:after) 3 # Clean up, so that the controller can be collected after this request 4 self.controller = nil 5 end ソースを読む:after_cont
roller_act ion処理の呼び出し 1 def callback(timing) 2 controller
_callback_ method_nam e = "#{ timing}_#{controller .controller _name.underscore }" 3 action_cal lback_meth od_name = "#{controller _callback_ method_nam e}_#{controller .action_nam e}" 4 send!(controller _callback_ method_nam e) if respond_to ?(controller _callback_ method_nam e, true) 5 send!(action_cal lback_meth od_name) if respond_to ?(action_cal lback_meth od_name, true) 6 end
最後の、"send!(action...:
愛が足りないながんばろ。
posted by
satoko
on Mon 14 Jan 2008
at 06:32