Module: BSON::TimeWithZone
- Defined in:
- lib/bson/time_with_zone.rb
Overview
Injects behaviour for encoding ActiveSupport::TimeWithZone values to raw bytes as specified by the BSON spec for time.
Instance Method Summary collapse
-
#bson_type ⇒ Object
Get the BSON type for the ActiveSupport::TimeWithZone.
-
#to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) ⇒ BSON::ByteBuffer
Get the ActiveSupport::TimeWithZone as encoded BSON.
Instance Method Details
#bson_type ⇒ Object
Get the BSON type for the ActiveSupport::TimeWithZone.
As the ActiveSupport::TimeWithZone is converted to a time, this returns the BSON type for time.
45 46 47 |
# File 'lib/bson/time_with_zone.rb', line 45 def bson_type ::Time::BSON_TYPE end |
#to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) ⇒ BSON::ByteBuffer
Get the ActiveSupport::TimeWithZone as encoded BSON.
37 38 39 |
# File 'lib/bson/time_with_zone.rb', line 37 def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_int64((to_i * 1000) + (usec / 1000)) end |