Module: BSON::Object
- Defined in:
- lib/bson/object.rb
Overview
Injects behaviour for all Ruby objects.
Instance Method Summary collapse
-
#as_extended_json(**_options) ⇒ Object
Converts this object to a representation directly serializable to Extended JSON (github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
-
#to_bson_key ⇒ Object
Objects that don’t override this method will raise an error when trying to use them as keys in a BSON document.
-
#to_bson_normalized_key ⇒ Object
Converts the object to a normalized key in a BSON document.
-
#to_bson_normalized_value ⇒ Object
Converts the object to a normalized value in a BSON document.
-
#to_extended_json(**options) ⇒ String
Serializes this object to Extended JSON (github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
Instance Method Details
#as_extended_json(**_options) ⇒ Object
Converts this object to a representation directly serializable to Extended JSON (github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
Subclasses should override this method to provide custom serialization to Extended JSON.
84 85 86 |
# File 'lib/bson/object.rb', line 84 def as_extended_json(**) self end |
#to_bson_key ⇒ Object
Objects that don’t override this method will raise an error when trying to use them as keys in a BSON document. This is only overridden in String and Symbol.
36 37 38 |
# File 'lib/bson/object.rb', line 36 def to_bson_key raise Error::InvalidKey.new(self) end |
#to_bson_normalized_key ⇒ Object
Converts the object to a normalized key in a BSON document.
48 49 50 |
# File 'lib/bson/object.rb', line 48 def to_bson_normalized_key self end |
#to_bson_normalized_value ⇒ Object
Converts the object to a normalized value in a BSON document.
60 61 62 |
# File 'lib/bson/object.rb', line 60 def to_bson_normalized_value self end |
#to_extended_json(**options) ⇒ String
Serializes this object to Extended JSON (github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
Subclasses should override as_extended_json
rather than this method.
73 74 75 |
# File 'lib/bson/object.rb', line 73 def to_extended_json(**) as_extended_json(**).to_json end |