diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2010-04-10 22:19:38 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-04-10 22:37:36 -0700 |
commit | 86dda361e2363e27d39cc66d490335d9c7126c7b (patch) | |
tree | 0eac0be11b5ad9137d4e5647b21dfd3bf4036151 /activerecord/lib/active_record | |
parent | 61355c0e243c4b6d9324479c96ef31e922f0355b (diff) | |
download | rails-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')
8 files changed, 24 insertions, 12 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 20a8754b7c..d94cc03938 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1,5 +1,6 @@ -require 'active_support/core_ext/module/delegation' +require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/enumerable' +require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/object/blank' module ActiveRecord @@ -1707,9 +1708,9 @@ module ActiveRecord silence_warnings do self.parent.const_set(extension_module_name, Module.new(&block_extension)) end - Array(extensions).push("#{self.parent}::#{extension_module_name}".constantize) + Array.wrap(extensions).push("#{self.parent}::#{extension_module_name}".constantize) else - Array(extensions) + Array.wrap(extensions) end end diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index b808f8c306..6a4cef0d50 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -1,4 +1,5 @@ require 'set' +require 'active_support/core_ext/array/wrap' module ActiveRecord module Associations @@ -98,7 +99,7 @@ module ActiveRecord if @target.is_a?(Array) @target.to_ary else - Array(@target) + Array.wrap(@target) end end alias_method :to_a, :to_ary diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb index 4fb1df3ab9..b9d0fe3abe 100644 --- a/activerecord/lib/active_record/associations/association_proxy.rb +++ b/activerecord/lib/active_record/associations/association_proxy.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/array/wrap' + module ActiveRecord module Associations # This is the root class of all association proxies: @@ -55,7 +57,7 @@ module ActiveRecord @owner, @reflection = owner, reflection @updated = false reflection.check_validity! - Array(reflection.options[:extend]).each { |ext| proxy_extend(ext) } + Array.wrap(reflection.options[:extend]).each { |ext| proxy_extend(ext) } reset end 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) diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 6d4ab501fa..e8cba1bd41 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/array/wrap' + module ActiveRecord module ConnectionAdapters # :nodoc: module SchemaStatements @@ -267,7 +269,7 @@ module ActiveRecord # generates # CREATE UNIQUE INDEX by_branch_party ON accounts(branch_id, party_id) def add_index(table_name, column_name, options = {}) - column_names = Array(column_name) + column_names = Array.wrap(column_name) index_name = index_name(table_name, :column => column_names) if Hash === options # legacy support, since this param was a string @@ -297,7 +299,7 @@ module ActiveRecord def index_name(table_name, options) #:nodoc: if Hash === options # legacy support if options[:column] - "index_#{table_name}_on_#{Array(options[:column]) * '_and_'}" + "index_#{table_name}_on_#{Array.wrap(options[:column]) * '_and_'}" elsif options[:name] options[:name] else diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index b5e8b7570a..2fbccb69db 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -1,3 +1,4 @@ +require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/object/blank' module ActiveRecord @@ -26,7 +27,7 @@ module ActiveRecord new_relation = clone new_relation.send(:apply_modules, Module.new(&block)) if block_given? value = build_where(*args) - new_relation.#{query_method}_values += [*value] if value.present? + new_relation.#{query_method}_values += Array.wrap(value) if value.present? new_relation end CEVAL diff --git a/activerecord/lib/active_record/serializers/xml_serializer.rb b/activerecord/lib/active_record/serializers/xml_serializer.rb index b19920741e..2e85959b1e 100644 --- a/activerecord/lib/active_record/serializers/xml_serializer.rb +++ b/activerecord/lib/active_record/serializers/xml_serializer.rb @@ -1,3 +1,4 @@ +require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/hash/conversions' module ActiveRecord #:nodoc: @@ -186,7 +187,7 @@ module ActiveRecord #:nodoc: end def serializable_method_attributes - Array(options[:methods]).inject([]) do |method_attributes, name| + Array.wrap(options[:methods]).inject([]) do |method_attributes, name| method_attributes << MethodAttribute.new(name.to_s, @serializable) if @serializable.respond_to?(name.to_s) method_attributes end diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb index 4806fa0ecc..6283bdd0d6 100644 --- a/activerecord/lib/active_record/validations/uniqueness.rb +++ b/activerecord/lib/active_record/validations/uniqueness.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/array/wrap' + module ActiveRecord module Validations class UniquenessValidator < ActiveModel::EachValidator @@ -19,7 +21,7 @@ module ActiveRecord relation = table.where(sql, *params) - Array(options[:scope]).each do |scope_item| + Array.wrap(options[:scope]).each do |scope_item| scope_value = record.send(scope_item) relation = relation.where(scope_item => scope_value) end |