diff options
author | Michael Koziarski <michael@koziarski.com> | 2008-06-04 11:05:46 +1200 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-06-04 11:05:46 +1200 |
commit | e3c26e9926948587efcc8d31c729395093407df6 (patch) | |
tree | 358f418791a56620c32a48776739b4fdf39d3cb0 /activesupport/lib/active_support/core_ext | |
parent | b9a9b91a3e3b892ab72ff5c618181747d6b4be04 (diff) | |
parent | 8afa725f4b98a6e0ceee4792e8ebaebb6189e5f6 (diff) | |
download | rails-e3c26e9926948587efcc8d31c729395093407df6.tar.gz rails-e3c26e9926948587efcc8d31c729395093407df6.tar.bz2 rails-e3c26e9926948587efcc8d31c729395093407df6.zip |
Merge branch 'master' into patches
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date/calculations.rb | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/hash/slice.rb | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/date/calculations.rb b/activesupport/lib/active_support/core_ext/date/calculations.rb index 1e2dbf118e..b5180c9592 100644 --- a/activesupport/lib/active_support/core_ext/date/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date/calculations.rb @@ -184,7 +184,7 @@ module ActiveSupport #:nodoc: # Returns a new Date/DateTime representing the end of the quarter (last day of march, june, september, december; DateTime objects will have time set to 23:59:59) def end_of_quarter - change(:month => [3, 6, 9, 12].detect { |m| m >= self.month }).end_of_month + beginning_of_month.change(:month => [3, 6, 9, 12].detect { |m| m >= self.month }).end_of_month end alias :at_end_of_quarter :end_of_quarter diff --git a/activesupport/lib/active_support/core_ext/hash/slice.rb b/activesupport/lib/active_support/core_ext/hash/slice.rb index 6fe5e05330..1b2c8f63e3 100644 --- a/activesupport/lib/active_support/core_ext/hash/slice.rb +++ b/activesupport/lib/active_support/core_ext/hash/slice.rb @@ -15,7 +15,9 @@ module ActiveSupport #:nodoc: # Returns a new hash with only the given keys. def slice(*keys) allowed = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys) - reject { |key,| !allowed.include?(key) } + hash = {} + allowed.each { |k| hash[k] = self[k] if has_key?(k) } + hash end # Replaces the hash with only the given keys. |