Class: Virtus::Attribute::Time

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

Overview

Time

Examples:

class Post
  include Virtus

  attribute :published_at, Time
end

Post.new(:published_at => Time.now)

# typecasting from a string
Post.new(:published_at => '2011/06/09 11:08')

# typecasting from a hash
Post.new(:published_at => {
  :year  => 2011,
  :month => 6,
  :day   => 9,
  :hour  => 11,
  :min   => 8,
})

# typecasting from an object which implements #to_time
Post.new(:published_at => DateTime.now)

Constant Summary

Constants included from TypeLookup

TypeLookup::TYPE_FORMAT

Instance Attribute Summary

Attributes inherited from Virtus::Attribute

#coercion_method, #default, #name, #options

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 TypeLookup

#determine_type, extended, #primitive

Methods included from Options

#accept_options, #accepted_options, #options

Constructor Details

This class inherits a constructor from Virtus::Attribute