Class: Neo4j::Shared::TypeConverters::BigDecimalConverter

Inherits:
BaseConverter
  • Object
show all
Defined in:
lib/neo4j/shared/type_converters.rb

Class Method Summary collapse

Methods inherited from BaseConverter

converted?, #supports_array?

Class Method Details

.convert_typeObject



64
65
66
# File 'lib/neo4j/shared/type_converters.rb', line 64

def convert_type
  BigDecimal
end

.db_typeObject



68
69
70
# File 'lib/neo4j/shared/type_converters.rb', line 68

def db_type
  BigDecimal
end

.to_db(value) ⇒ Object Also known as: to_ruby



72
73
74
75
76
77
78
79
80
81
# File 'lib/neo4j/shared/type_converters.rb', line 72

def to_db(value)
  case value
  when Rational
    value.to_f.to_d
  when respond_to?(:to_d)
    value.to_d
  else
    BigDecimal.new(value.to_s)
  end
end