diff --git a/lib/mongo/util/ordered_hash.rb b/lib/mongo/util/ordered_hash.rb index 0448eb6..2e05fc9 100644 --- a/lib/mongo/util/ordered_hash.rb +++ b/lib/mongo/util/ordered_hash.rb @@ -15,8 +15,14 @@ # ++ # A hash in which the order of keys are preserved. +# +# Under Ruby 1.9 and greater, this class has no added methods because Ruby's +# Hash already keeps its keys ordered by order of insertion. class OrderedHash < Hash + # We only need the body of this class if the RUBY_VERSION is before 1.9 + if RUBY_VERSION < '1.9' + attr_accessor :ordered_keys def keys @@ -57,4 +63,6 @@ class OrderedHash < Hash str << '}' end + end # Ruby before 1.9 + end