Class: ActiveGraph::Shared::TypeConverters::IntegerConverter

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

Constant Summary collapse

NEO4J_LARGEST_INT =
9223372036854775807
NEO4J_SMALLEST_INT =
-9223372036854775808

Class Method Summary collapse

Methods inherited from BaseConverter

#supports_array?

Class Method Details

.convert_typeObject



35
36
37
# File 'lib/active_graph/shared/type_converters.rb', line 35

def convert_type
  Integer
end

.converted?(value) ⇒ Boolean

Returns:



31
32
33
# File 'lib/active_graph/shared/type_converters.rb', line 31

def converted?(value)
  false
end

.db_typeObject



39
40
41
# File 'lib/active_graph/shared/type_converters.rb', line 39

def db_type
  Integer
end

.to_db(value) ⇒ Object



43
44
45
46
# File 'lib/active_graph/shared/type_converters.rb', line 43

def to_db(value)
  val = value.to_i
  val > NEO4J_LARGEST_INT || val < NEO4J_SMALLEST_INT ? val.to_s : val
end

.to_ruby(value) ⇒ Object



48
49
50
# File 'lib/active_graph/shared/type_converters.rb', line 48

def to_ruby(value)
  value.to_i
end