aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/callbacks.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2010-04-10 22:19:38 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2010-04-10 22:37:36 -0700
commit86dda361e2363e27d39cc66d490335d9c7126c7b (patch)
tree0eac0be11b5ad9137d4e5647b21dfd3bf4036151 /activerecord/lib/active_record/callbacks.rb
parent61355c0e243c4b6d9324479c96ef31e922f0355b (diff)
downloadrails-86dda361e2363e27d39cc66d490335d9c7126c7b.tar.gz
rails-86dda361e2363e27d39cc66d490335d9c7126c7b.tar.bz2
rails-86dda361e2363e27d39cc66d490335d9c7126c7b.zip
Avoid deprecated String#to_a by using Array.wrap(...) instead of Array(...)
Diffstat (limited to 'activerecord/lib/active_record/callbacks.rb')
-rw-r--r--activerecord/lib/active_record/callbacks.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb
index add5d99ca6..98c14e6eb0 100644
--- a/activerecord/lib/active_record/callbacks.rb
+++ b/activerecord/lib/active_record/callbacks.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/array/wrap'
+
module ActiveRecord
# Callbacks are hooks into the lifecycle of an Active Record object that allow you to trigger logic
# before or after an alteration of the object state. This can be used to make sure that associated and
@@ -250,7 +252,7 @@ module ActiveRecord
def before_validation(*args, &block)
options = args.last
if options.is_a?(Hash) && options[:on]
- options[:if] = Array(options[:if])
+ options[:if] = Array.wrap(options[:if])
options[:if] << "@_on_validate == :#{options[:on]}"
end
set_callback(:validation, :before, *args, &block)
@@ -259,7 +261,7 @@ module ActiveRecord
def after_validation(*args, &block)
options = args.extract_options!
options[:prepend] = true
- options[:if] = Array(options[:if])
+ options[:if] = Array.wrap(options[:if])
options[:if] << "!halted && value != false"
options[:if] << "@_on_validate == :#{options[:on]}" if options[:on]
set_callback(:validation, :after, *(args << options), &block)