Permalink
Browse files

Remove Array.wrap calls in ActiveSupport

  • Loading branch information...
1 parent 2958a1e commit b33bd077fab8e249ba3ddfb7e656c34243c05a1d @rafaelfranca rafaelfranca committed Jan 6, 2012
@@ -1,6 +1,5 @@
require 'active_support/concern'
require 'active_support/descendants_tracker'
-require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/kernel/reporting'
require 'active_support/core_ext/kernel/singleton_class'
@@ -121,12 +120,12 @@ def clone(chain, klass)
end
def normalize_options!(options)
- options[:if] = Array.wrap(options[:if])
- options[:unless] = Array.wrap(options[:unless])
+ options[:if] = Array(options[:if])
+ options[:unless] = Array(options[:unless])
options[:per_key] ||= {}
- options[:per_key][:if] = Array.wrap(options[:per_key][:if])
- options[:per_key][:unless] = Array.wrap(options[:per_key][:unless])
+ options[:per_key][:if] = Array(options[:per_key][:if])
+ options[:per_key][:unless] = Array(options[:per_key][:unless])
end
def name
@@ -246,11 +245,11 @@ def _compile_options(options)
conditions = ["true"]
unless options[:if].empty?
- conditions << Array.wrap(_compile_filter(options[:if]))
+ conditions << Array(_compile_filter(options[:if]))
end
unless options[:unless].empty?
- conditions << Array.wrap(_compile_filter(options[:unless])).map {|f| "!#{f}"}
+ conditions << Array(_compile_filter(options[:unless])).map {|f| "!#{f}"}
end
conditions.flatten.join(" && ")
@@ -295,7 +294,7 @@ def _compile_filter(filter)
@klass.send(:define_method, "#{method_name}_object") { filter }
_normalize_legacy_filter(kind, filter)
- scopes = Array.wrap(chain.config[:scope])
+ scopes = Array(chain.config[:scope])
method_to_call = scopes.map{ |s| s.is_a?(Symbol) ? send(s) : s }.join("_")
@klass.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
@@ -1,5 +1,4 @@
require "active_support/notifications"
-require "active_support/core_ext/array/wrap"
module ActiveSupport
module Deprecation
@@ -19,7 +18,7 @@ def behavior
# ActiveSupport::Deprecation.behavior = :stderr
# ActiveSupport::Deprecation.behavior = [:stderr, :log]
def behavior=(behavior)
- @behavior = Array.wrap(behavior).map { |b| DEFAULT_BEHAVIORS[b] || b }
+ @behavior = Array(behavior).map { |b| DEFAULT_BEHAVIORS[b] || b }
end
end
@@ -1,4 +1,3 @@
-require "active_support/core_ext/array/wrap"
require "active_support/core_ext/array/extract_options"
module ActiveSupport
@@ -113,7 +112,7 @@ def compile_glob(hash) #:nodoc:
end
def compile_ext(array) #:nodoc:
- array = Array.wrap(array)
+ array = Array(array)
return if array.empty?
".{#{array.join(",")}}"
end
@@ -5,7 +5,6 @@
require 'bigdecimal'
require 'active_support/core_ext/big_decimal/conversions' # for #to_s
-require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/hash/except'
require 'active_support/core_ext/hash/slice'
require 'active_support/core_ext/object/instance_variables'
@@ -228,9 +227,9 @@ def as_json(options = nil) #:nodoc:
# create a subset of the hash by applying :only or :except
subset = if options
if attrs = options[:only]
- slice(*Array.wrap(attrs))
+ slice(*Array(attrs))
elsif attrs = options[:except]
- except(*Array.wrap(attrs))
+ except(*Array(attrs))
else
self
end
@@ -19,7 +19,7 @@ def initialize(logger)
def tagged(*new_tags)
tags = current_tags
- new_tags = Array.wrap(new_tags).flatten.reject(&:blank?)
+ new_tags = Array(new_tags).flatten.reject(&:blank?)
tags.concat new_tags
yield
ensure
@@ -1,4 +1,3 @@
-require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/object/blank'
module ActiveSupport
@@ -45,7 +44,7 @@ module Assertions
# post :delete, :id => ...
# end
def assert_difference(expression, difference = 1, message = nil, &block)
- expressions = Array.wrap expression
+ expressions = Array(expression)
exps = expressions.map { |e|
e.respond_to?(:call) ? e : lambda { eval(e, block.binding) }

0 comments on commit b33bd07

Please sign in to comment.