module BSON::BigDecimal
Injects behaviour for encoding and decoding BigDecimals to and from raw bytes as specified by the BSON
spec.
Constants
- BSON_TYPE
BigDecimals are serialized as Decimal128s under the hood. A
Decimal128
is type 0x13 in theBSON
spec.
Public Instance Methods
bson_type()
click to toggle source
Get the BSON
type for BigDecimal
. This is the same BSON
type as BSON::Decimal128
.
# File lib/bson/big_decimal.rb, line 42 def bson_type BSON_TYPE end
to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?)
click to toggle source
Get the BigDecimal
as encoded BSON
.
@example Get the BigDecimal
as encoded BSON
.
BigDecimal("1").to_bson
@return [ BSON::ByteBuffer
] The buffer with the encoded object.
@see bsonspec.org/#/specification
# File lib/bson/big_decimal.rb, line 36 def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) BSON::Decimal128.new(to_s).to_bson(buffer, validating_keys) end