Change more Array.wrap to Kernel#Array

This commit is contained in:
Rafael Mendonça França 2012-01-05 17:18:54 -03:00
parent 56715c49d4
commit 2ed17977ac
9 changed files with 14 additions and 19 deletions

@ -1,7 +1,6 @@
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/hash/slice'
require 'active_support/core_ext/hash/except'
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/module/anonymous'
require 'action_dispatch/http/mime_types'
@ -43,9 +42,9 @@ module ActionController
# wrap_parameters :person, :include => [:username, :password]
# end
#
# On ActiveRecord models with no +:include+ or +:exclude+ option set,
# On ActiveRecord models with no +:include+ or +:exclude+ option set,
# if attr_accessible is set on that model, it will only wrap the accessible
# parameters, else it will only wrap the parameters returned by the class
# parameters, else it will only wrap the parameters returned by the class
# method attribute_names.
#
# If you're going to pass the parameters to an +ActiveModel+ object (such as
@ -180,9 +179,9 @@ def _set_wrapper_defaults(options, model=nil)
controller_name.singularize
end
options[:include] = Array.wrap(options[:include]).collect(&:to_s) if options[:include]
options[:exclude] = Array.wrap(options[:exclude]).collect(&:to_s) if options[:exclude]
options[:format] = Array.wrap(options[:format])
options[:include] = Array(options[:include]).collect(&:to_s) if options[:include]
options[:exclude] = Array(options[:exclude]).collect(&:to_s) if options[:exclude]
options[:format] = Array(options[:format])
self._wrapper_options = options
end

@ -50,7 +50,7 @@ def parameter_filter
end
def env_filter
parameter_filter_for(Array.wrap(@env["action_dispatch.parameter_filter"]) << /RAW_POST_DATA/)
parameter_filter_for(Array(@env["action_dispatch.parameter_filter"]) << /RAW_POST_DATA/)
end
def parameter_filter_for(filters)

@ -322,8 +322,8 @@ def time_zone_select(object, method, priority_zones = nil, options = {}, html_op
def options_for_select(container, selected = nil)
return container if String === container
selected, disabled = extract_selected_and_disabled(selected).map do | r |
Array.wrap(r).map { |item| item.to_s }
selected, disabled = extract_selected_and_disabled(selected).map do |r|
Array(r).map { |item| item.to_s }
end
container.map do |element|

@ -1,4 +1,3 @@
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/module/remove_method'
@ -29,7 +28,7 @@ def #{name}
end
def #{name}=(value)
value = value.present? ? Array.wrap(value) : default_#{name}
value = value.present? ? Array(value) : default_#{name}
_set_detail(:#{name}, value) if value != @details[:#{name}]
end

@ -17,7 +17,7 @@ def extract_details(options)
details = {}
@lookup_context.registered_details.each do |key|
next unless value = options[key]
details[key] = Array.wrap(value)
details[key] = Array(value)
end
details
end

@ -1,5 +1,4 @@
require 'active_support/core_ext/object/try'
require 'active_support/core_ext/array/wrap'
module ActionView
class TemplateRenderer < AbstractRenderer #:nodoc:

@ -1,4 +1,3 @@
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/object/try'
require 'active_support/core_ext/kernel/singleton_class'
@ -122,7 +121,7 @@ def initialize(source, identifier, handler, details)
@locals = details[:locals] || []
@virtual_path = details[:virtual_path]
@updated_at = details[:updated_at] || Time.now
@formats = Array.wrap(format).map { |f| f.is_a?(Mime::Type) ? f.ref : f }
@formats = Array(format).map { |f| f.is_a?(Mime::Type) ? f.ref : f }
end
# Returns if the underlying handler supports streaming. If so,

@ -1,4 +1,3 @@
require "active_support/core_ext/array/wrap"
require "active_support/core_ext/enumerable"
module ActionView
@ -30,7 +29,7 @@ class MissingTemplate < ActionViewError #:nodoc:
def initialize(paths, path, prefixes, partial, details, *)
@path = path
prefixes = Array.wrap(prefixes)
prefixes = Array(prefixes)
template_type = if partial
"partial"
elsif path =~ /layouts/i

@ -254,7 +254,7 @@ def get(thing, *args)
end
def assert_body(body)
assert_equal body, Array.wrap(response.body).join
assert_equal body, Array(response.body).join
end
def assert_status(code)
@ -262,7 +262,7 @@ def assert_status(code)
end
def assert_response(body, status = 200, headers = {})
assert_body body
assert_body body
assert_status status
headers.each do |header, value|
assert_header header, value