time_parsing.rb

Path: lib/couchrest/model/core_extensions/time_parsing.rb
Last Update: Sat Feb 23 07:11:41 +0000 2019

Methods

as_json  

Public Instance methods

Override the ActiveSupport‘s Time#as_json method to ensure that we always encode using the iso8601 format and include fractional digits (3 by default).

Including miliseconds in Time is very important for CouchDB to ensure that order is preserved between models created in the same second.

The number of fraction digits can be set by providing it in the options:

   time.as_json(:fraction_digits => 6)

The CouchRest Model time_fraction_digits configuration option is used for the default fraction. Given the global nature of Time#as_json method, this configuration option can only be set for the whole project.

   CouchRest::Model::Base.time_fraction_digits = 6

[Validate]