aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2013-10-11 13:05:29 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2013-10-11 13:05:29 -0700
commit365110196afcf952bc22729d4467d579b708328f (patch)
tree7525a43f663b790929004b504ad92f9cb4d5b63f /activesupport
parentcc362fe17b9a3e4be34a6a5a9f97f9c271bd7513 (diff)
downloadrails-365110196afcf952bc22729d4467d579b708328f.tar.gz
rails-365110196afcf952bc22729d4467d579b708328f.tar.bz2
rails-365110196afcf952bc22729d4467d579b708328f.zip
Revert "Merge pull request #12480 from iwiznia/master"
This reverts commit e5f5a838b96a362534d9bb60d02334439ed9784c, reversing changes made to d7567f3290a50952494e9213556a1f283a6cf3a0.
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/CHANGELOG.md7
-rw-r--r--activesupport/lib/active_support/duration.rb20
-rw-r--r--activesupport/test/core_ext/duration_test.rb15
3 files changed, 0 insertions, 42 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index 478fef2baf..f1dd7c312d 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -1,10 +1,3 @@
-* Add `flatten` and `flatten!` methods to Duration objects.
-
- Example:
- Date.today + (1.month + 1.month).flatten == Date.today + 2.months
-
- *Ionatan Wiznia*
-
* `require_dependency` accepts objects that respond to `to_path`, in
particular `Pathname` instances.
diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb
index 1db0ca51ae..87b6407038 100644
--- a/activesupport/lib/active_support/duration.rb
+++ b/activesupport/lib/active_support/duration.rb
@@ -81,18 +81,6 @@ module ActiveSupport
to_i
end
- # Flattens all the +parts+ of the duration, and returns a
- # new duration object.
- def flatten
- Duration.new(@value, flatten_parts)
- end
-
- # Flattens all the +parts+ of this duration.
- def flatten!
- @parts = flatten_parts
- self
- end
-
protected
def sum(sign, time = ::Time.current) #:nodoc:
@@ -109,14 +97,6 @@ module ActiveSupport
end
end
- def flatten_parts
- @parts.inject({}) do |result, (name, value)|
- result[name] ||= 0
- result[name] += value
- result
- end.to_a
- end
-
private
def method_missing(method, *args, &block) #:nodoc:
diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb
index cc24d7c74c..ed267cf4b9 100644
--- a/activesupport/test/core_ext/duration_test.rb
+++ b/activesupport/test/core_ext/duration_test.rb
@@ -145,21 +145,6 @@ class DurationTest < ActiveSupport::TestCase
assert_equal '172800', 2.days.to_json
end
- def test_flatten
- a = 2.months
- b = (1.month + 1.month).flatten
-
- assert_equal a.parts, b.parts
- end
-
- def test_flatten!
- a = (1.month + 1.month)
- b = a.flatten
- a.flatten!
-
- assert_equal a.parts, b.parts
- end
-
protected
def with_env_tz(new_tz = 'US/Eastern')
old_tz, ENV['TZ'] = ENV['TZ'], new_tz