From 7ed8934f089dba8cbb90a98920cd4242ba5e0fd3 Mon Sep 17 00:00:00 2001 From: Pablo Cantero Date: Sat, 27 Jul 2013 13:54:39 -0300 Subject: Minor refactor - Uses Enumerable#to_a instead of iterate and add to an array --- activesupport/lib/active_support/core_ext/array/grouping.rb | 4 +--- activesupport/lib/active_support/core_ext/date/calculations.rb | 2 +- activesupport/lib/active_support/core_ext/hash/conversions.rb | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/array/grouping.rb b/activesupport/lib/active_support/core_ext/array/grouping.rb index dbddc7a7b4..ef737ffc43 100644 --- a/activesupport/lib/active_support/core_ext/array/grouping.rb +++ b/activesupport/lib/active_support/core_ext/array/grouping.rb @@ -31,9 +31,7 @@ class Array if block_given? collection.each_slice(number) { |slice| yield(slice) } else - groups = [] - collection.each_slice(number) { |group| groups << group } - groups + collection.each_slice(number).to_a end end diff --git a/activesupport/lib/active_support/core_ext/date/calculations.rb b/activesupport/lib/active_support/core_ext/date/calculations.rb index 06e4847e82..eddb1b851f 100644 --- a/activesupport/lib/active_support/core_ext/date/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date/calculations.rb @@ -119,7 +119,7 @@ class Date options.fetch(:day, day) ) end - + # Allow Date to be compared with Time by converting to DateTime and relying on the <=> from there. def compare_with_coercion(other) if other.is_a?(Time) diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb index 8930376ac8..fbf2877117 100644 --- a/activesupport/lib/active_support/core_ext/hash/conversions.rb +++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb @@ -235,7 +235,6 @@ module ActiveSupport value.map! { |i| deep_to_h(i) } value.length > 1 ? value : value.first end - end end -- cgit v1.2.3