Module: Mongoid::Extensions::TimeWithZone
- Defined in:
- lib/mongoid/extensions/time_with_zone.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#__mongoize_time__ ⇒ ActiveSupport::TimeWithZone
Mongoizes an ActiveSupport::TimeWithZone into a time.
-
#_bson_to_i ⇒ Object
This code is copied from Time class extension in bson-ruby gem.
-
#mongoize ⇒ Time
Turn the object from the ruby type we deal with to a Mongo friendly type.
Instance Method Details
#__mongoize_time__ ⇒ ActiveSupport::TimeWithZone
Mongoizes an ActiveSupport::TimeWithZone into a time.
TimeWithZone always mongoize into TimeWithZone instances (which are themselves).
13 14 15 |
# File 'lib/mongoid/extensions/time_with_zone.rb', line 13 def __mongoize_time__ self end |
#_bson_to_i ⇒ Object
This code is copied from Time class extension in bson-ruby gem. It should be removed from here when added to bson-ruby. See jira.mongodb.org/browse/RUBY-2846.
31 32 33 34 35 36 37 38 39 |
# File 'lib/mongoid/extensions/time_with_zone.rb', line 31 def _bson_to_i # Workaround for JRuby's #to_i rounding negative timestamps up # rather than down (https://github.com/jruby/jruby/issues/6104) if BSON::Environment.jruby? (self - usec.to_r/1000000).to_i else to_i end end |
#mongoize ⇒ Time
Turn the object from the ruby type we deal with to a Mongo friendly type.
24 25 26 |
# File 'lib/mongoid/extensions/time_with_zone.rb', line 24 def mongoize ::ActiveSupport::TimeWithZone.mongoize(self) end |