From a5688fa9073dc8824d98071346e6cd9ae417eb72 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Wed, 27 May 2009 11:02:13 -0700 Subject: Add the ability to prepend filters to new callbacks --- activesupport/lib/active_support/new_callbacks.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/new_callbacks.rb') diff --git a/activesupport/lib/active_support/new_callbacks.rb b/activesupport/lib/active_support/new_callbacks.rb index b6cbdbb6b0..e9a30b9c35 100644 --- a/activesupport/lib/active_support/new_callbacks.rb +++ b/activesupport/lib/active_support/new_callbacks.rb @@ -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) -- cgit v1.2.3