diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-01-31 23:55:04 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-01-31 23:55:04 +0000 |
commit | 2504982945828d24c9b799c408d71576508b4c15 (patch) | |
tree | 153a081b3ee884894798bc6fa6f9adcb1eee6110 /actionpack/lib/action_controller/filters.rb | |
parent | 2bf3fa076e822da1e55064ca7e9409af3fe52841 (diff) | |
download | rails-2504982945828d24c9b799c408d71576508b4c15.tar.gz rails-2504982945828d24c9b799c408d71576508b4c15.tar.bz2 rails-2504982945828d24c9b799c408d71576508b4c15.zip |
Added :only and :except controls to skip_before/after_filter just like for when you add filters [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3504 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/filters.rb')
-rw-r--r-- | actionpack/lib/action_controller/filters.rb | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/filters.rb b/actionpack/lib/action_controller/filters.rb index 3f712629db..0149d52303 100644 --- a/actionpack/lib/action_controller/filters.rb +++ b/actionpack/lib/action_controller/filters.rb @@ -251,18 +251,34 @@ module ActionController #:nodoc: # Removes the specified filters from the +before+ filter chain. Note that this only works for skipping method-reference # filters, not procs. This is especially useful for managing the chain in inheritance hierarchies where only one out # of many sub-controllers need a different hierarchy. + # + # You can control the actions to skip the filter for with the <tt>:only</tt> and <tt>:except</tt> options, + # just like when you apply the filters. def skip_before_filter(*filters) - for filter in filters.flatten - write_inheritable_attribute("before_filters", read_inheritable_attribute("before_filters") - [ filter ]) + if conditions = extract_conditions!(filters) + conditions[:only], conditions[:except] = conditions[:except], conditions[:only] + add_action_conditions(filters, conditions) + else + for filter in filters.flatten + write_inheritable_attribute("before_filters", read_inheritable_attribute("before_filters") - [ filter ]) + end end end # Removes the specified filters from the +after+ filter chain. Note that this only works for skipping method-reference # filters, not procs. This is especially useful for managing the chain in inheritance hierarchies where only one out # of many sub-controllers need a different hierarchy. + # + # You can control the actions to skip the filter for with the <tt>:only</tt> and <tt>:except</tt> options, + # just like when you apply the filters. def skip_after_filter(*filters) - for filter in filters.flatten - write_inheritable_attribute("after_filters", read_inheritable_attribute("after_filters") - [ filter ]) + if conditions = extract_conditions!(filters) + conditions[:only], conditions[:except] = conditions[:except], conditions[:only] + add_action_conditions(filters, conditions) + else + for filter in filters.flatten + write_inheritable_attribute("after_filters", read_inheritable_attribute("after_filters") - [ filter ]) + end end end |