-
Type:
Task
-
Resolution: Won't Do
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
Ruby Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Currently BSON::Document behaves as follows:
doc = BSON::Document.new({"foo" => "bar"}) doc.to_h.class #=> Hash -- CORRECT Hash(doc).class #=> BSON::Document -- non-optimal / confusing
Defining `BSON::Document#to_hash` as an alias to `.to_h` would fix this. Since the content of BSON::Document is 1-to-1 equivalent to a hash, it makes sense to do.
Compare for reference the equivalent method `BSON::ObjectId#to_str` which enables us to do:
String(BSON::ObjectId.new).class #=> String
(For clarity, this is only for BSON::Document, am NOT proposing the same for Mongoid::Document)