Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added ActiveSupport::OrderedHash#each_key and ActiveSupport::OrderedH…

…ash#each_value [#1410 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
commit 05a938c5f7804fd59c76c45df096e6ebff871a18 1 parent 63d8f56
Christoffer Sawicki qerub authored lifo committed
2  activesupport/CHANGELOG
View
@@ -1,5 +1,7 @@
*2.3.0 [Edge]*
+* Added ActiveSupport::OrderedHash#each_key and ActiveSupport::OrderedHash#each_value #1410 [Christoffer Sawicki]
+
* Added ActiveSupport::MessageVerifier and MessageEncryptor to aid users who need to store signed and/or encrypted messages. [Koz]
* Added ActiveSupport::BacktraceCleaner to cut down on backtrace noise according to filters and silencers [DHH]
8 activesupport/lib/active_support/ordered_hash.rb
View
@@ -53,6 +53,14 @@ def has_value?(v)
end
alias_method :value?, :has_value?
+
+ def each_key
+ each { |key, value| yield key }
+ end
+
+ def each_value
+ each { |key, value| yield value }
+ end
end
end
end
12 activesupport/test/ordered_hash_test.rb
View
@@ -61,4 +61,16 @@ def test_has_value
assert_equal false, @ordered_hash.has_value?('ABCABC')
assert_equal false, @ordered_hash.value?('ABCABC')
end
+
+ def test_each_key
+ keys = []
+ @ordered_hash.each_key { |k| keys << k }
+ assert_equal @keys, keys
+ end
+
+ def test_each_value
+ values = []
+ @ordered_hash.each_value { |v| values << v }
+ assert_equal @values, values
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.