Sha256: 2c684f5f45a284bbef591287641e00d6fdfe9fa4b065892b81e4bdcfaea7b64f

Contents?: true

Size: 820 Bytes

Versions: 18

Compression:

Stored size: 820 Bytes

Contents

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

18 entries across 18 versions & 2 rubygems

Version Path
virtus-0.5.5 lib/virtus/attribute/date_time.rb
virtus-0.5.4 lib/virtus/attribute/date_time.rb
virtus-0.5.3 lib/virtus/attribute/date_time.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/virtus-0.5.2/lib/virtus/attribute/date_time.rb
virtus-0.5.2 lib/virtus/attribute/date_time.rb
virtus-0.5.1 lib/virtus/attribute/date_time.rb
virtus-0.5.0 lib/virtus/attribute/date_time.rb
virtus-0.4.2 lib/virtus/attribute/date_time.rb
virtus-0.4.1 lib/virtus/attribute/date_time.rb
virtus-0.4.0 lib/virtus/attribute/date_time.rb
virtus-0.3.0 lib/virtus/attribute/date_time.rb
virtus-0.2.0 lib/virtus/attribute/date_time.rb
virtus-0.1.0 lib/virtus/attribute/date_time.rb
virtus-0.0.10 lib/virtus/attribute/date_time.rb
virtus-0.0.9 lib/virtus/attribute/date_time.rb
virtus-0.0.8 lib/virtus/attribute/date_time.rb
virtus-0.0.7 lib/virtus/attribute/date_time.rb
virtus-0.0.6 lib/virtus/attribute/date_time.rb