Sha256: 4f5066e028806ea2ed07ce908c065f86a667dea30e887dfd4f0c4c4f2cfed5a7

Contents?: true

Size: 845 Bytes

Versions: 2

Compression:

Stored size: 845 Bytes

Contents

motion_require 'object'

module Virtus
  class Attribute

    # DateTime
    #
    # @example
    #   class Post
    #     include Virtus
    #
    #     attribute :published_at, DateTime
    #   end
    #
    #   Post.new(:published_at => DateTime.now)
    #
    #   # typecasting from a string
    #   Post.new(:published_on => '2011/06/09 10:48')
    #
    #   # typecasting from a hash
    #   Post.new(:published_on => {
    #     :year  => 2011,
    #     :month => 6,
    #     :day   => 9,
    #     :hour  => 10,
    #     :min   => 48,
    #   })
    #
    #   # typecasting from an object which implements #to_datetime
    #   Post.new(:published_on => Time.now)
    #
    class DateTime < Object
      primitive       ::DateTime
      coercion_method :to_datetime

    end # class DateTim
  end # class Attribute
end # module Virtus

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
motion_virtus-1.0.0.beta0.1 lib/project/attribute/date_time.rb
motion_virtus-1.0.0.beta0 lib/project/attribute/date_time.rb