Sha256: f7b29d05a801bb82a3fdb7c7570a111554f63884f0aefbffec9c761e9ab8e6d2
Contents?: true
Size: 676 Bytes
Versions: 3
Compression:
Stored size: 676 Bytes
Contents
# frozen_string_literal: true module Acfs::Resource::Attributes # @api public # # DateTime attribute type. Use it in your model as # an attribute type: # # @example # class User < Acfs::Resource # attribute :name, :date_time # end # class DateTime < Base # @api public # # Cast given object to DateTime. # # @param [Object] value Object to cast. # @return [DateTime] Casted object as DateTime. # def cast_value(value) if value.blank? nil elsif value.acts_like?(:time) || value.acts_like?(:date) value.to_datetime else ::DateTime.iso8601 value end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
acfs-1.5.0 | lib/acfs/resource/attributes/date_time.rb |
acfs-1.4.0 | lib/acfs/resource/attributes/date_time.rb |
acfs-1.3.4 | lib/acfs/resource/attributes/date_time.rb |