Sha256: dc627b0568d7519651d71f72fba95ed83bcbdf4215417a55a52fc587d579c38d

Contents?: true

Size: 689 Bytes

Versions: 87

Compression:

Stored size: 689 Bytes

Contents

module Acfs::Model::Attributes

  # @api public
  #
  # DateTime attribute type. Use it in your model as an attribute type:
  #
  # @example
  #   class User
  #     include Acfs::Model
  #     attribute :name, :date_time
  #   end
  #
  class DateTime < 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

87 entries across 87 versions & 1 rubygems

Version Path
acfs-0.34.0 lib/acfs/model/attributes/date_time.rb
acfs-0.33.1.1.b285 lib/acfs/model/attributes/date_time.rb
acfs-0.33.1.1.b281 lib/acfs/model/attributes/date_time.rb
acfs-0.33.1 lib/acfs/model/attributes/date_time.rb
acfs-0.33.0.1.b278 lib/acfs/model/attributes/date_time.rb
acfs-0.33.0 lib/acfs/model/attributes/date_time.rb
acfs-0.32.1.1.b277 lib/acfs/model/attributes/date_time.rb
acfs-0.32.1.1.b276 lib/acfs/model/attributes/date_time.rb
acfs-0.32.1.1.b275 lib/acfs/model/attributes/date_time.rb
acfs-0.32.1.1.b274 lib/acfs/model/attributes/date_time.rb
acfs-0.32.1.1.b272 lib/acfs/model/attributes/date_time.rb
acfs-0.32.1 lib/acfs/model/attributes/date_time.rb
acfs-0.32.0.1.b270 lib/acfs/model/attributes/date_time.rb
acfs-0.31.0.1.b269 lib/acfs/model/attributes/date_time.rb
acfs-0.32.0 lib/acfs/model/attributes/date_time.rb
acfs-0.31.0.1.b265 lib/acfs/model/attributes/date_time.rb
acfs-0.31.0.1.b263 lib/acfs/model/attributes/date_time.rb
acfs-0.31.0 lib/acfs/model/attributes/date_time.rb
acfs-0.30.0.1.b262 lib/acfs/model/attributes/date_time.rb
acfs-0.30.0.1.b261 lib/acfs/model/attributes/date_time.rb