diff options
author | chaitanyav <me@chaitanyavellanki.com> | 2010-06-26 01:52:20 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-26 12:05:25 +0200 |
commit | 9958950f78638e4a6c6800404d84f22effc0748e (patch) | |
tree | a1c96fd8cae120ae64f68eaf916ba7f424be7460 /activesupport/lib/active_support | |
parent | d4e1a2ef0d35f322803284a980575fc31ff7b4b6 (diff) | |
download | rails-9958950f78638e4a6c6800404d84f22effc0748e.tar.gz rails-9958950f78638e4a6c6800404d84f22effc0748e.tar.bz2 rails-9958950f78638e4a6c6800404d84f22effc0748e.zip |
Add OrderedHash#invert to preserve order in ruby 1.8 [#4875]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/ordered_hash.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb index a19d6c3532..6b563b9063 100644 --- a/activesupport/lib/active_support/ordered_hash.rb +++ b/activesupport/lib/active_support/ordered_hash.rb @@ -162,6 +162,10 @@ module ActiveSupport self end + def invert + OrderedHash[self.to_a.map!{|key_value_pair| key_value_pair.reverse}] + end + def inspect "#<OrderedHash #{super}>" end |