lib/active_model/callbacks.rb in activemodel-3.0.0.beta vs lib/active_model/callbacks.rb in activemodel-3.0.0.beta2

- old
+ new

@@ -1,5 +1,6 @@ +require 'active_support/core_ext/array/wrap' require 'active_support/callbacks' module ActiveModel # == Active Model Callbacks # @@ -89,11 +90,11 @@ # def define_model_callbacks(*callbacks) options = callbacks.extract_options! options = { :terminator => "result == false", :scope => [:kind, :name] }.merge(options) - types = Array(options.delete(:only)) + types = Array.wrap(options.delete(:only)) types = [:before, :around, :after] if types.empty? callbacks.each do |callback| define_callbacks(callback, options) @@ -122,12 +123,12 @@ def _define_after_model_callback(klass, callback) #:nodoc: klass.class_eval <<-CALLBACK, __FILE__, __LINE__ def self.after_#{callback}(*args, &block) options = args.extract_options! options[:prepend] = true - options[:if] = Array(options[:if]) << "!halted && value != false" + options[:if] = Array.wrap(options[:if]) << "!halted && value != false" set_callback(:#{callback}, :after, *(args << options), &block) end CALLBACK end end -end \ No newline at end of file +end