aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/ordered_hash.rb
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-08-06 01:50:54 -0400
committerNeeraj Singh <neerajdotname@gmail.com>2010-08-06 01:51:11 -0400
commitcdbc880055fba8bfa63b2c3c5fda94c48f87b037 (patch)
treee168ac0fcd2d792d043aec4be8942db808e0ffd8 /activesupport/lib/active_support/ordered_hash.rb
parentd0ac56b5b4194bdf36bbd3b49ad64649b0675c66 (diff)
downloadrails-cdbc880055fba8bfa63b2c3c5fda94c48f87b037.tar.gz
rails-cdbc880055fba8bfa63b2c3c5fda94c48f87b037.tar.bz2
rails-cdbc880055fba8bfa63b2c3c5fda94c48f87b037.zip
adding documentation for OrderedHash and OrderedOptions
Diffstat (limited to 'activesupport/lib/active_support/ordered_hash.rb')
-rw-r--r--activesupport/lib/active_support/ordered_hash.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb
index 6b563b9063..e19d9d7dc1 100644
--- a/activesupport/lib/active_support/ordered_hash.rb
+++ b/activesupport/lib/active_support/ordered_hash.rb
@@ -4,7 +4,14 @@ YAML.add_builtin_type("omap") do |type, val|
ActiveSupport::OrderedHash[val.map(&:to_a).map(&:first)]
end
-# OrderedHash is namespaced to prevent conflicts with other implementations
+# Hash is not ordered in ruby 1.8.x. What it means is there is no guarantee of order of keys when
+# method Hash#keys in invoked. Similarly Hash#values and Hash#each can't guarantee that each time
+# the output will contain exactly same value in the same order. <tt>OrderedHash</tt> solves that
+# problem.
+#
+# ActiveSupport::OrderedHash[:boy, 'John', :girl, 'Mary']
+#
+# OrderedHash is namespaced to prevent conflicts with other implementations.
module ActiveSupport
class OrderedHash < ::Hash #:nodoc:
def to_yaml_type