Class: ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Float

Inherits:
Type::Float show all
Includes:
Infinity
Defined in:
activerecord/lib/active_record/connection_adapters/postgresql/oid/float.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Type::Value

#limit, #precision, #scale

Instance Method Summary collapse

Methods included from Infinity

#infinity

Methods inherited from Type::Float

#type

Methods included from Type::Numeric

#changed?, #number?, #type_cast

Methods inherited from Type::Value

#==, #binary?, #changed?, #changed_in_place?, #hash, #initialize, #klass, #number?, #text?, #type, #type_cast_for_database, #type_cast_for_schema, #type_cast_from_database, #type_cast_from_user

Constructor Details

This class inherits a constructor from ActiveRecord::Type::Value

Instance Method Details

#cast_value(value) ⇒ Object


8
9
10
11
12
13
14
15
16
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid/float.rb', line 8

def cast_value(value)
  case value
  when ::Float then     value
  when 'Infinity' then  ::Float::INFINITY
  when '-Infinity' then -::Float::INFINITY
  when 'NaN' then       ::Float::NAN
  else                  value.to_f
  end
end