# File lib/couchrest/model/typecast.rb, line 5 def typecast_value(parent, property, value) return nil if value.nil? type = property.type if value.instance_of?(type) || type == Object if type == Time && !value.utc? value.utc # Ensure Time is always in UTC else value end elsif type.respond_to?(:couchrest_typecast) type.couchrest_typecast(parent, property, value) elsif [String, Symbol, TrueClass, Integer, Float, BigDecimal, DateTime, Time, Date, Class].include?(type) send('typecast_to_'+type.to_s.downcase, value) else property.build(value) end end