Sha256: 1555eb3c87ae5bf0599307cbe72258a53b192c28def91c4f9ee48e2a02265464
Contents?: true
Size: 1.07 KB
Versions: 15
Compression:
Stored size: 1.07 KB
Contents
# Copyright 2020 Google LLC # # Use of this source code is governed by an MIT-style # license that can be found in the LICENSE file or at # https://opensource.org/licenses/MIT. # frozen_string_literal: true module ActiveRecord module Type module Spanner class Time < ActiveRecord::Type::Time def serialize_with_isolation_level value, isolation_level if value == :commit_timestamp return "PENDING_COMMIT_TIMESTAMP()" if isolation_level == :dml return "spanner.commit_timestamp()" if isolation_level == :mutation end serialize value end def serialize value val = super value val.acts_like?(:time) ? val.utc.rfc3339(9) : val end def user_input_in_time_zone value return value.in_time_zone if value.is_a? ::Time super value end private def cast_value value if value.is_a? ::String value = value.empty? ? nil : ::Time.parse(value) end value end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems