Sha256: 7285b55a9c3140f90b28678800ce56a5ba283e3cc8aa0aea4a7843016583ae62

Contents?: true

Size: 668 Bytes

Versions: 2

Compression:

Stored size: 668 Bytes

Contents

module Acfs::Model::Attributes

  # @api public
  #
  # DateTime attribute type. Use it in your model as an attribute type:
  #
  # @example
  #   class User< Acfs::Resoruce
  #     attribute :name, :uuid
  #   end
  #
  class Uuid < Base

    # @api public
    #
    # Cast given object to DateTime.
    # Expect
    #
    # @param [Object] obj Object to cast.
    # @return [DateTime] Casted object as DateTime.
    #
    def cast_type(obj)
      return nil if nil_allowed? and obj.blank?
      return obj if obj.is_a? ::DateTime
      return ::DateTime.iso8601(obj.iso8601) if obj.is_a? Time or obj.is_a? Date
      return ::DateTime.iso8601(obj)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acfs-0.31.0 lib/acfs/model/attributes/uuid.rb
acfs-0.30.0 lib/acfs/model/attributes/uuid.rb