Skip to content
Browse files

let ruby decompose the tuples in the iterator

  • Loading branch information...
1 parent 5edfc46 commit 3a91d44eff00476e399b3246871f4760817ecf9e @tenderlove tenderlove committed Aug 6, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 activesupport/lib/active_support/duration.rb
View
2 activesupport/lib/active_support/duration.rb
@@ -70,7 +70,7 @@ def ago(time = ::Time.current)
alias :until :ago
def inspect #:nodoc:
- consolidated = parts.inject(::Hash.new(0)) { |h,part| h[part.first] += part.last; h }
+ consolidated = parts.inject(::Hash.new(0)) { |h,(l,r)| h[l] += r; h }
parts = [:years, :months, :days, :minutes, :seconds].map do |length|
n = consolidated[length]
"#{n} #{n == 1 ? length.to_s.singularize : length.to_s}" if n.nonzero?

0 comments on commit 3a91d44

Please sign in to comment.
Something went wrong with that request. Please try again.