Module: BSON::OpenStruct
- Defined in:
- lib/bson/open_struct.rb
Overview
Injects behaviour for encoding OpenStruct objects using hashes to raw bytes as specified by the BSON spec.
Instance Method Summary collapse
-
#bson_type ⇒ String
The BSON type for OpenStruct objects is the Hash type of 0x03.
-
#to_bson(buffer = ByteBuffer.new) ⇒ BSON::ByteBuffer
Get the OpenStruct as encoded BSON.
Instance Method Details
#bson_type ⇒ String
The BSON type for OpenStruct objects is the Hash type of 0x03.
53 54 55 |
# File 'lib/bson/open_struct.rb', line 53 def bson_type ::Hash::BSON_TYPE end |
#to_bson(buffer = ByteBuffer.new) ⇒ BSON::ByteBuffer
Get the OpenStruct as encoded BSON.
37 38 39 40 41 42 43 |
# File 'lib/bson/open_struct.rb', line 37 def to_bson(buffer = ByteBuffer.new) if Environment.ruby_1_9? marshal_dump.dup else to_h end.to_bson(buffer) end |