Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::Money
- Inherits:
-
Type
- Object
- Type
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::Money
show all
- Defined in:
- activerecord/lib/active_record/connection_adapters/postgresql/oid.rb
Instance Method Summary
collapse
Methods inherited from Type
#type, #type_cast_for_write
Instance Method Details
#type_cast(value) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb', line 39
def type_cast(value)
return if value.nil?
case value
when /^-?\D+[\d,]+\.\d{2}$/ value.gsub!(/[^-\d.]/, '')
when /^-?\D+[\d.]+,\d{2}$/ value.gsub!(/[^-\d,]/, '').sub!(/,/, '.')
end
ConnectionAdapters::Column.value_to_decimal value
end
|