diff options
author | Xavier Noria <fxn@hashref.com> | 2010-12-24 01:55:12 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-12-24 01:55:12 +0100 |
commit | 3822673151cd0f53e0e4e671988e35603bf2901c (patch) | |
tree | f1d54c60d3dfdfc6a1b854dedff649eb39fe4287 /railties/guides/source/active_support_core_extensions.textile | |
parent | 0b5222fa45ff8da340ca4f086d735e97b7fb7326 (diff) | |
parent | d1e95e12b4d56fac58ee680fd2d8d5cdac57b2ac (diff) | |
download | rails-3822673151cd0f53e0e4e671988e35603bf2901c.tar.gz rails-3822673151cd0f53e0e4e671988e35603bf2901c.tar.bz2 rails-3822673151cd0f53e0e4e671988e35603bf2901c.zip |
Merge branch 'master' of git://github.com/lifo/docrails
Diffstat (limited to 'railties/guides/source/active_support_core_extensions.textile')
-rw-r--r-- | railties/guides/source/active_support_core_extensions.textile | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index bddff1c987..33e281d59b 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1568,7 +1568,7 @@ The method +tableize+ is +underscore+ followed by +pluralize+. "InvoiceLine".tableize # => "invoice_lines" </ruby> -As a rule of thumb, +tableize+ returns the table name that corresponds to a given model for simple cases. The actual implementation in Active Record is not straight +tableize+ indeed, because it also demodulizes de class name and checks a few options that may affect the returned string. +As a rule of thumb, +tableize+ returns the table name that corresponds to a given model for simple cases. The actual implementation in Active Record is not straight +tableize+ indeed, because it also demodulizes the class name and checks a few options that may affect the returned string. NOTE: Defined in +active_support/core_ext/string/inflections.rb+. @@ -1868,7 +1868,7 @@ The sum of an empty collection is zero by default, but this is customizable: [].sum(1) # => 1 </ruby> -If a block is given +sum+ becomes an iterator that yields the elements of the collection and sums the returned values: +If a block is given, +sum+ becomes an iterator that yields the elements of the collection and sums the returned values: <ruby> (1..5).sum {|n| n * 2 } # => 30 @@ -1896,7 +1896,7 @@ h4. +each_with_object+ The +inject+ method offers iteration with an accumulator: <ruby> -[2, 3, 4].inject(1) {|acc, i| product*i } # => 24 +[2, 3, 4].inject(1) {|product, i| product*i } # => 24 </ruby> The block is expected to return the value for the accumulator in the next iteration, and this makes building mutable objects a bit cumbersome: @@ -1942,7 +1942,7 @@ The method +many?+ is shorthand for +collection.size > 1+: <% end %> </erb> -If an optional block is given +many?+ only takes into account those elements that return true: +If an optional block is given, +many?+ only takes into account those elements that return true: <ruby> @see_more = videos.many? {|video| video.category == params[:category]} @@ -1952,7 +1952,7 @@ NOTE: Defined in +active_support/core_ext/enumerable.rb+. h4. +exclude?+ -The predicate +exclude?+ tests whether a given object does *not* belong to the collection. It is the negation of the builtin +include?+: +The predicate +exclude?+ tests whether a given object does *not* belong to the collection. It is the negation of the built-in +include?+: <ruby> to_visit << node if visited.exclude?(node) |