Sha256: 677226bbde4457eaec3881fffbb57134438b25cfe61f3b74b1b690e400f43bf0
Contents?: true
Size: 896 Bytes
Versions: 10
Compression:
Stored size: 896 Bytes
Contents
require 'date' module Attributor class Time < Temporal include Type def self.native_type return ::Time end def self.example(context=nil, options: {}) return self.load(/[:time:]/.gen, context) end def self.load(value,context=Attributor::DEFAULT_ROOT_CONTEXT, **options) return value if value.is_a?(self.native_type) return nil if value.nil? return value.to_time if value.respond_to?(:to_time) case value when ::Integer return ::Time.at(value) when ::String begin return ::Time.parse(value) rescue ArgumentError => e raise Attributor::DeserializationError, context: context, from: value.class, encoding: "Time" , value: value end else raise CoercionError, context: context, from: value.class, to: self, value: value end end end end
Version data entries
10 entries across 10 versions & 1 rubygems