Sha256: 121d5de13bfac4050ff9bb1b64e84fa3e0abce834b4696262843df835016314b
Contents?: true
Size: 890 Bytes
Versions: 10
Compression:
Stored size: 890 Bytes
Contents
require 'date' module Attributor class Date < Temporal def self.native_type return ::Date end def self.example(context=nil, options: {}) return self.load(/[:date:]/.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_date if value.respond_to?(:to_date) case value when ::String begin return ::Date.parse(value) rescue ArgumentError => e raise Attributor::DeserializationError, context: context, from: value.class, encoding: "Date" , 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