TimeWithZone#advance: leverage Hash#values_at and non-block form of #any? for a little less line noise, and a slight speedup (thanks raggi and Roman2K)

This commit is contained in:
Geoff Buesing
2009-02-09 23:12:47 -06:00
parent 16cc69af6f
commit 3c6bf82115

View File

@@ -230,7 +230,7 @@ module ActiveSupport
def advance(options)
# If we're advancing a value of variable length (i.e., years, weeks, months, days), advance from #time,
# otherwise advance from #utc, for accuracy when moving across DST boundaries
if options.any? {|k,v| [:years, :weeks, :months, :days].include? k}
if options.values_at(:years, :weeks, :months, :days).any?
method_missing(:advance, options)
else
utc.advance(options).in_time_zone(time_zone)