lib/virtus/attribute/time.rb in virtus-0.0.5 vs lib/virtus/attribute/time.rb in virtus-0.0.6

- old
+ new

@@ -1,10 +1,11 @@ module Virtus class Attribute - # Example usage: + # Time # + # @example # class Post # include Virtus # # attribute :published_at, Time # end @@ -14,30 +15,22 @@ # # 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, - # :minutes => 8 + # :year => 2011, + # :month => 6, + # :day => 9, + # :hour => 11, + # :min => 8, # }) # # # typecasting from an object which implements #to_time # Post.new(:published_at => DateTime.now) # class Time < Object - primitive ::Time - - # @see Virtus::Typecast::Time.to_time - # - # @return [Time] - # - # @api private - def typecast_to_primitive(value) - Typecast::Time.to_time(value) - end + primitive ::Time + coercion_method :to_time end # class Time end # class Attribute end # module Virtus