Class: Virtus::Attribute::DateTime

Inherits:
Object show all
Defined in:
lib/virtus/attribute/date_time.rb

Overview

DateTime

Examples:

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)

Constant Summary

Constants included from TypeLookup

TypeLookup::EXTRA_CONST_ARGS, TypeLookup::TYPE_FORMAT

Instance Attribute Summary

Attributes inherited from Virtus::Attribute

#coercion_method, #default, #instance_variable_name, #name, #options, #reader_visibility, #writer_visibility

Method Summary

Methods inherited from Virtus::Attribute

build, #coerce, #define_accessor_methods, #define_reader_method, #define_writer_method, determine_type, #get, #get!, #initialize, #inspect, merge_options, #public_reader?, #public_writer?, #set, #set!, #value_coerced?

Methods included from DescendantsTracker

#add_descendant, #descendants

Methods included from TypeLookup

#determine_type, #primitive

Methods included from Options

#accept_options, #accepted_options, #options

Constructor Details

This class inherits a constructor from Virtus::Attribute