diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-11-26 20:04:00 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-11-26 20:04:00 +0100 |
commit | e2362babdf16079727966dea046bdd2ee67e716d (patch) | |
tree | 57d03786603e85292dd16b1194ccf5fc78028bd8 /activesupport | |
parent | 4999d52e08a02ebba344f6c318f0af4b5b18f0e5 (diff) | |
parent | 9a4d557713acb0fc8e80f61af18094034aca029a (diff) | |
download | rails-e2362babdf16079727966dea046bdd2ee67e716d.tar.gz rails-e2362babdf16079727966dea046bdd2ee67e716d.tar.bz2 rails-e2362babdf16079727966dea046bdd2ee67e716d.zip |
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/CHANGELOG | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/ordered_hash.rb | 8 | ||||
-rw-r--r-- | activesupport/lib/active_support/xml_mini.rb | 2 | ||||
-rw-r--r-- | activesupport/test/ordered_hash_test.rb | 12 |
4 files changed, 23 insertions, 1 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index 9e7dc458b4..d142f21d61 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -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] diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb index 9757054e43..5de94c67e0 100644 --- a/activesupport/lib/active_support/ordered_hash.rb +++ b/activesupport/lib/active_support/ordered_hash.rb @@ -53,6 +53,14 @@ module ActiveSupport 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 diff --git a/activesupport/lib/active_support/xml_mini.rb b/activesupport/lib/active_support/xml_mini.rb index d0b660f7bd..bfc3d7b00b 100644 --- a/activesupport/lib/active_support/xml_mini.rb +++ b/activesupport/lib/active_support/xml_mini.rb @@ -17,7 +17,7 @@ module XmlMini # string:: # XML Document string to parse def parse(string) - require 'rexml/document' + require 'rexml/document' unless defined?(REXML::Document) doc = REXML::Document.new(string) merge_element!({}, doc.root) end diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb index 98a6ad6b26..17dffbd624 100644 --- a/activesupport/test/ordered_hash_test.rb +++ b/activesupport/test/ordered_hash_test.rb @@ -61,4 +61,16 @@ class OrderedHashTest < Test::Unit::TestCase 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 |