Sha256: cd649f90d0e5618bd65c61cfb62afdd77556697d3042a5cc90bf66bb7b6fc9d9
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
# typed: strict # frozen_string_literal: true module Yogurt module Converters class Date extend T::Sig extend ScalarConverter sig {override.returns(T::Types::Base)} def self.type_alias T.type_alias {::Date} end sig {override.params(value: ::Date).returns(String)} def self.serialize(value) value.iso8601 end sig {override.params(raw_value: SCALAR_TYPE).returns(::Date)} def self.deserialize(raw_value) raise "Unexpected value returned for Date: #{raw_value.inspect}" if !raw_value.is_a?(String) ::Date.iso8601(raw_value) end end class Time extend T::Sig extend ScalarConverter sig {override.returns(T::Types::Base)} def self.type_alias T.type_alias {::Time} end sig {override.params(value: ::Time).returns(String)} def self.serialize(value) value.iso8601 end sig {override.params(raw_value: SCALAR_TYPE).returns(::Time)} def self.deserialize(raw_value) raise "Unexpected value returned for Time: #{raw_value.inspect}" if !raw_value.is_a?(String) ::Time.iso8601(raw_value) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yogurt-0.2.0 | lib/yogurt/converters.rb |
yogurt-0.1.1 | lib/yogurt/converters.rb |