aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/ordered_options.rb6
-rw-r--r--activesupport/test/core_ext/enumerable_test.rb1
3 files changed, 9 insertions, 0 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 52a6da97f5..de13f03310 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Add OrderedHash#to_hash [josh]
+
* Adding Time#end_of_day, _quarter, _week, and _year. #9312 [Juanjo Bazan, Tarmo Tänav, BigTitus]
* Adding TimeWithZone#between? [Geoff Buesing]
diff --git a/activesupport/lib/active_support/ordered_options.rb b/activesupport/lib/active_support/ordered_options.rb
index 1542a2479e..b2b1b0e438 100644
--- a/activesupport/lib/active_support/ordered_options.rb
+++ b/activesupport/lib/active_support/ordered_options.rb
@@ -26,6 +26,12 @@ module ActiveSupport
def values
collect { |key, value| value }
end
+
+ def to_hash
+ returning({}) do |hash|
+ each { |array| hash[array[0]] = array[1] }
+ end
+ end
end
end
end
diff --git a/activesupport/test/core_ext/enumerable_test.rb b/activesupport/test/core_ext/enumerable_test.rb
index 9567f22e9a..f5facd54ad 100644
--- a/activesupport/test/core_ext/enumerable_test.rb
+++ b/activesupport/test/core_ext/enumerable_test.rb
@@ -22,6 +22,7 @@ class EnumerableTests < Test::Unit::TestCase
end
assert_equal objects.uniq.map(&:name), grouped.keys
+ assert({}.merge(grouped), "Could not convert ActiveSupport::OrderedHash into Hash")
end
def test_sums