Module: BSON::BigDecimal
- Defined in:
- lib/bson/big_decimal.rb
Overview
Injects behaviour for encoding and decoding BigDecimals to and from raw bytes as specified by the BSON spec.
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- BSON_TYPE =
BigDecimals are serialized as Decimal128s under the hood. A Decimal128 is type 0x13 in the BSON spec.
::String.new(19.chr, encoding: BINARY).freeze
Instance Method Summary collapse
-
#bson_type ⇒ Object
Get the BSON type for BigDecimal.
-
#to_bson(buffer = ByteBuffer.new) ⇒ BSON::ByteBuffer
Get the BigDecimal as encoded BSON.
Instance Method Details
#bson_type ⇒ Object
Get the BSON type for BigDecimal. This is the same BSON type as BSON::Decimal128.
43 44 45 |
# File 'lib/bson/big_decimal.rb', line 43 def bson_type BSON_TYPE end |
#to_bson(buffer = ByteBuffer.new) ⇒ BSON::ByteBuffer
Get the BigDecimal as encoded BSON.
37 38 39 |
# File 'lib/bson/big_decimal.rb', line 37 def to_bson(buffer = ByteBuffer.new) BSON::Decimal128.new(to_s).to_bson(buffer) end |