diff options
| author | eparreno <emili@eparreno.com> | 2010-11-15 22:16:17 +0100 |
|---|---|---|
| committer | eparreno <emili@eparreno.com> | 2010-11-15 22:16:17 +0100 |
| commit | ca4b4c0baa240baea0eaf372283dbd33ec671b6a (patch) | |
| tree | 0ca0ee53b1d03d76f82c3ba481da53c1e5499084 /actionpack/lib/abstract_controller/callbacks.rb | |
| parent | 04775a41cbbddceeffa9cf8590566b9990fd4070 (diff) | |
| parent | 91a6db90cf8b2c07af4cf64a9c587268106aadd5 (diff) | |
| download | rails-ca4b4c0baa240baea0eaf372283dbd33ec671b6a.tar.gz rails-ca4b4c0baa240baea0eaf372283dbd33ec671b6a.tar.bz2 rails-ca4b4c0baa240baea0eaf372283dbd33ec671b6a.zip | |
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'actionpack/lib/abstract_controller/callbacks.rb')
| -rw-r--r-- | actionpack/lib/abstract_controller/callbacks.rb | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/actionpack/lib/abstract_controller/callbacks.rb b/actionpack/lib/abstract_controller/callbacks.rb index 7b0d80614d..f169ab7c3a 100644 --- a/actionpack/lib/abstract_controller/callbacks.rb +++ b/actionpack/lib/abstract_controller/callbacks.rb @@ -81,27 +81,29 @@ module AbstractController class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 # Append a before, after or around filter. See _insert_callbacks # for details on the allowed parameters. - def #{filter}_filter(*names, &blk) # def before_filter(*names, &blk) - _insert_callbacks(names, blk) do |name, options| # _insert_callbacks(names, blk) do |name, options} - set_callback(:process_action, :#{filter}, name, options) # set_callback(:process_action, :before_filter, name, options) - end # end - end # end + def #{filter}_filter(*names, &blk) + _insert_callbacks(names, blk) do |name, options| + options[:if] = (Array.wrap(options[:if]) << "!halted") if #{filter == :after} + set_callback(:process_action, :#{filter}, name, options) + end + end # Prepend a before, after or around filter. See _insert_callbacks # for details on the allowed parameters. - def prepend_#{filter}_filter(*names, &blk) # def prepend_before_filter(*names, &blk) - _insert_callbacks(names, blk) do |name, options| # _insert_callbacks(names, blk) do |name, options| - set_callback(:process_action, :#{filter}, name, options.merge(:prepend => true)) # set_callback(:process_action, :before, name, options.merge(:prepend => true)) - end # end - end # end + def prepend_#{filter}_filter(*names, &blk) + _insert_callbacks(names, blk) do |name, options| + options[:if] = (Array.wrap(options[:if]) << "!halted") if #{filter == :after} + set_callback(:process_action, :#{filter}, name, options.merge(:prepend => true)) + end + end # Skip a before, after or around filter. See _insert_callbacks # for details on the allowed parameters. - def skip_#{filter}_filter(*names, &blk) # def skip_before_filter(*names, &blk) - _insert_callbacks(names, blk) do |name, options| # _insert_callbacks(names, blk) do |name, options| - skip_callback(:process_action, :#{filter}, name, options) # skip_callback(:process_action, :before, name, options) - end # end - end # end + def skip_#{filter}_filter(*names, &blk) + _insert_callbacks(names, blk) do |name, options| + skip_callback(:process_action, :#{filter}, name, options) + end + end # *_filter is the same as append_*_filter alias_method :append_#{filter}_filter, :#{filter}_filter |
