aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/active_support_core_extensions.textile
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-07-30 02:35:24 +0200
committerXavier Noria <fxn@hashref.com>2010-07-30 02:35:24 +0200
commitccd45618ed9a629c9535a5ff84ef5c238befa4ab (patch)
tree0a582bf695dce01240762d2b8516efde43bc3515 /railties/guides/source/active_support_core_extensions.textile
parent3c3ff1377d17b584dd14d85c7cecab59ddff2679 (diff)
parent755af497555fde16db86f7e51f6462b0aca79b49 (diff)
downloadrails-ccd45618ed9a629c9535a5ff84ef5c238befa4ab.tar.gz
rails-ccd45618ed9a629c9535a5ff84ef5c238befa4ab.tar.bz2
rails-ccd45618ed9a629c9535a5ff84ef5c238befa4ab.zip
Merge remote branch 'rails/master'
Diffstat (limited to 'railties/guides/source/active_support_core_extensions.textile')
-rw-r--r--railties/guides/source/active_support_core_extensions.textile9
1 files changed, 8 insertions, 1 deletions
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile
index 6ee7a4220b..fcf4ae29ba 100644
--- a/railties/guides/source/active_support_core_extensions.textile
+++ b/railties/guides/source/active_support_core_extensions.textile
@@ -2214,7 +2214,14 @@ NOTE: Defined in +active_support/core_ext/array/conversions.rb+.
h4. Wrapping
-The class method +Array.wrap+ behaves like the function +Array()+ except that it does not try to call +to_a+ on its argument. That changes the behavior for enumerables:
+The class method +Array.wrap+ behaves like the function +Array()+ except:
+
+* If the argument responds to +to_ary+ the method is invoked. <tt>Kernel#Array</tt> moves on to try +to_a+ if the returned value is +nil+, but <tt>Arraw.wrap</tt> returns such a +nil+ right away.
+* If the returned value from +to_ary+ is neither +nil+ nor an +Array+ object, <tt>Kernel#Array</tt> raises an exception, while <tt>Array.wrap</tt> does not, it just returns the value.
+* It does not call +to_a+ on the argument, though special-cases +nil+ to return an empty array.
+
+
+ that it does not try to call +to_a+ on its argument. That changes the behavior for enumerables:
<ruby>
Array.wrap(:foo => :bar) # => [{:foo => :bar}]