aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorMarcel Molina <marcel@vernix.org>2006-05-17 05:12:53 +0000
committerMarcel Molina <marcel@vernix.org>2006-05-17 05:12:53 +0000
commit36d1a2f302817815e0e70334733d2daf1a14a4f5 (patch)
tree077921312cbd11b2205ed7aa4d30059f014d711a /activesupport/lib/active_support
parentff96498848d6a9f58707d4d9848a196643d45c26 (diff)
downloadrails-36d1a2f302817815e0e70334733d2daf1a14a4f5.tar.gz
rails-36d1a2f302817815e0e70334733d2daf1a14a4f5.tar.bz2
rails-36d1a2f302817815e0e70334733d2daf1a14a4f5.zip
Make Array#in_groups_of just return the grouped collection if a block isn't given. [Marcel Molina Jr.]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4345 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/array.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/array.rb b/activesupport/lib/active_support/core_ext/array.rb
index db6f5587da..243aeab423 100644
--- a/activesupport/lib/active_support/core_ext/array.rb
+++ b/activesupport/lib/active_support/core_ext/array.rb
@@ -16,7 +16,11 @@ class Array #:nodoc:
require 'enumerator'
collection = dup
collection << fill_with until collection.size.modulo(number).zero?
- collection.each_slice(number, &block)
+ grouped_collection = [] unless block_given?
+ collection.each_slice(number) do |group|
+ block_given? ? yield(group) : grouped_collection << group
+ end
+ grouped_collection unless block_given?
end
# Divide the array into one or more subarrays based on a delimiting +value+