From 586fe4dc725ef9a92d39de1a4cac0ff6524b1b93 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 22 Sep 2009 09:31:59 +0200 Subject: AS guide: documents Enumerable#many? --- railties/guides/source/active_support_overview.textile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/railties/guides/source/active_support_overview.textile b/railties/guides/source/active_support_overview.textile index 3f6e9b306d..fde50b08ec 100644 --- a/railties/guides/source/active_support_overview.textile +++ b/railties/guides/source/active_support_overview.textile @@ -884,6 +884,22 @@ invoices.index_by(&:number) WARNING. Keys should normally be unique. If the block returns the same value for different elements no collection is built for that key. The last item will win. +h4. +many?+ + +The method +many?+ is shorthand for +collection.size > 1+: + + +<% if pages.many? %> + <%= pagination_links %> +<% end %> + + +If an optional block is given +many?+ only takes into account those elements that return true: + + +@see_more = videos.many? {|video| video.category == params[:category]} + + h3. Extensions to +Array+ h4. Accessing -- cgit v1.2.3