From ef0da581e94be1c938202cfa7ed39fb29614e570 Mon Sep 17 00:00:00 2001 From: Subba Rao Pasupuleti Date: Tue, 3 Aug 2010 17:04:41 -0400 Subject: no callbacks should be created for empty array [#5289 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activemodel/lib/active_model/callbacks.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'activemodel/lib/active_model') diff --git a/activemodel/lib/active_model/callbacks.rb b/activemodel/lib/active_model/callbacks.rb index 8c10c54b54..b150fc60f7 100644 --- a/activemodel/lib/active_model/callbacks.rb +++ b/activemodel/lib/active_model/callbacks.rb @@ -90,10 +90,13 @@ module ActiveModel # def define_model_callbacks(*callbacks) options = callbacks.extract_options! - options = { :terminator => "result == false", :scope => [:kind, :name] }.merge(options) + options = { + :terminator => "result == false", + :scope => [:kind, :name], + :only => [:before, :around, :after] + }.merge(options) - types = Array.wrap(options.delete(:only)) - types = [:before, :around, :after] if types.empty? + types = Array.wrap(options.delete(:only)) callbacks.each do |callback| define_callbacks(callback, options) -- cgit v1.2.3