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, validating_keys = Config.validating_keys?) ⇒ 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.
51 52 53 |
# File 'lib/bson/open_struct.rb', line 51 def bson_type ::Hash::BSON_TYPE end |
#to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) ⇒ BSON::ByteBuffer
Get the OpenStruct as encoded BSON.
35 36 37 38 39 40 41 |
# File 'lib/bson/open_struct.rb', line 35 def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) if Environment.ruby_1_9? marshal_dump.dup else to_h end.to_bson(buffer, validating_keys) end |