aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/abstract
diff options
context:
space:
mode:
authorYehuda Katz <wycats@yehuda-katzs-macbookpro41.local>2009-06-02 19:00:59 -0700
committerYehuda Katz <wycats@yehuda-katzs-macbookpro41.local>2009-06-02 19:00:59 -0700
commit971e2438d98326c994ec6d3ef8e37b7e868ed6e2 (patch)
tree3a746ec6e845b7956775055a1a2453bd46eb6eb4 /actionpack/lib/action_controller/abstract
parent196f780e30fcece25e4d09c12f9b9f7374ebed29 (diff)
downloadrails-971e2438d98326c994ec6d3ef8e37b7e868ed6e2.tar.gz
rails-971e2438d98326c994ec6d3ef8e37b7e868ed6e2.tar.bz2
rails-971e2438d98326c994ec6d3ef8e37b7e868ed6e2.zip
Simplify callbacks to use less metaprogramming
Diffstat (limited to 'actionpack/lib/action_controller/abstract')
-rw-r--r--actionpack/lib/action_controller/abstract/callbacks.rb30
1 files changed, 15 insertions, 15 deletions
diff --git a/actionpack/lib/action_controller/abstract/callbacks.rb b/actionpack/lib/action_controller/abstract/callbacks.rb
index affe053bac..dd4213e847 100644
--- a/actionpack/lib/action_controller/abstract/callbacks.rb
+++ b/actionpack/lib/action_controller/abstract/callbacks.rb
@@ -32,32 +32,32 @@ module AbstractController
skip_around_filter(*names, &blk)
end
+ def _insert_callbacks(names, block)
+ options = names.last.is_a?(Hash) ? names.pop : {}
+ _normalize_callback_options(options)
+ names.push(block) if block
+ names.each do |name|
+ yield name, options
+ end
+ end
+
[:before, :after, :around].each do |filter|
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def #{filter}_filter(*names, &blk)
- options = names.last.is_a?(Hash) ? names.pop : {}
- _normalize_callback_options(options)
- names.push(blk) if block_given?
- names.each do |name|
- process_action_callback(:#{filter}, name, options)
+ _insert_callbacks(names, blk) do |name, options|
+ _set_callback(:process_action, :#{filter}, name, options)
end
end
def prepend_#{filter}_filter(*names, &blk)
- options = names.last.is_a?(Hash) ? names.pop : {}
- _normalize_callback_options(options)
- names.push(blk) if block_given?
- names.each do |name|
- process_action_callback(:#{filter}, name, options.merge(:prepend => true))
+ _insert_callbacks(names, blk) do |name, options|
+ _set_callback(:process_action, :#{filter}, name, options.merge(:prepend => true))
end
end
def skip_#{filter}_filter(*names, &blk)
- options = names.last.is_a?(Hash) ? names.pop : {}
- _normalize_callback_options(options)
- names.push(blk) if block_given?
- names.each do |name|
- skip_process_action_callback(:#{filter}, name, options)
+ _insert_callbacks(names, blk) do |name, options|
+ _skip_callback(:process_action, :#{filter}, name, options)
end
end