mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add the ability to prepend filters to new callbacks
This commit is contained in:
parent
760cb63339
commit
a5688fa907
2 changed files with 12 additions and 1 deletions
|
@ -37,6 +37,15 @@ module AbstractController
|
|||
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))
|
||||
end
|
||||
end
|
||||
|
||||
def skip_#{filter}_filter(*names, &blk)
|
||||
options = names.last.is_a?(Hash) ? names.pop : {}
|
||||
_normalize_callback_options(options)
|
||||
|
|
|
@ -464,7 +464,9 @@ module ActiveSupport
|
|||
self._#{symbol}_callbacks.delete_if {|c| c.matches?(type, :#{symbol}, filter)}
|
||||
Callback.new(filter, type, options.dup, self, :#{symbol})
|
||||
end
|
||||
self._#{symbol}_callbacks.push(*filters)
|
||||
options[:prepend] ?
|
||||
self._#{symbol}_callbacks.unshift(*filters) :
|
||||
self._#{symbol}_callbacks.push(*filters)
|
||||
_define_runner(:#{symbol},
|
||||
self._#{symbol}_callbacks.compile(nil, :terminator => _#{symbol}_terminator),
|
||||
options)
|
||||
|
|
Loading…
Reference in a new issue