Class: ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Money
- Inherits:
-
Type
- Object
- Type
- ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Money
show all
- Defined in:
- lib/arjdbc/postgresql/base/oid.rb
Instance Method Summary
collapse
Methods inherited from Type
#infinity, #simplified_type
Instance Method Details
#type ⇒ Object
79
|
# File 'lib/arjdbc/postgresql/base/oid.rb', line 79
def type; :decimal end
|
#type_cast(value) ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/arjdbc/postgresql/base/oid.rb', line 81
def type_cast(value)
return if value.nil?
return value unless ::String === value
value.sub!(/^\((.+)\)$/, '-\1') 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
|