Permalink
Browse files

Array.wrap no longer needed

  • Loading branch information...
1 parent f28fc93 commit b899b7be51271b0a6fddd9d95e1a58d782949565 @tenderlove tenderlove committed Jan 4, 2012
Showing with 2 additions and 3 deletions.
  1. +2 −3 activemodel/lib/active_model/mass_assignment_security.rb
@@ -1,6 +1,5 @@
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/string/inflections'
-require 'active_support/core_ext/array/wrap'
require 'active_model/mass_assignment_security/permission_set'
require 'active_model/mass_assignment_security/sanitizer'
@@ -116,7 +115,7 @@ def attr_protected(*args)
self._protected_attributes = protected_attributes_configs.dup
- Array.wrap(role).each do |name|
+ Array(role).each do |name|
self._protected_attributes[name] = self.protected_attributes(name) + args
end
@@ -178,7 +177,7 @@ def attr_accessible(*args)
self._accessible_attributes = accessible_attributes_configs.dup
- Array.wrap(role).each do |name|
+ Array(role).each do |name|
self._accessible_attributes[name] = self.accessible_attributes(name) + args
end

5 comments on commit b899b7b

Owner

rafaelfranca replied Jan 5, 2012

I saw more points in the Rails code base that I changed to use Kernel#Array and the tests still pass, like here. But I don't know if the tests cases are good enough to make sure that nothing will broke.

Is there any reason for this change? Should I try to remove others Array.wrap calls?

Owner

tenderlove replied Jan 5, 2012

Now that we've dropped 1.8 support, the main difference is between Array(:foo => :bar) and Array.wrap(:foo => :bar). If the places you find Array.wrap are not dealing with hashes, it's probably safe to change.

Owner

fxn replied Jan 5, 2012

The AS guide lists the differences among the two. Is there anything outdated? See http://guides.rubyonrails.org/active_support_core_extensions.html#wrapping

Owner

tenderlove replied Jan 5, 2012

The guides are correct but they contain a caveat for 1.8:

1.8 caveat

I suppose we could change that to be more 1.9 centric, but the guide is technically correct. :-)

Owner

fxn replied Jan 5, 2012

Excellent thanks Aaron :).

Please sign in to comment.