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



29
30
31
# File 'lib/active_graph/shared/type_converters.rb', line 29

def convert_type
  Integer
end

.converted?(value) ⇒ Boolean

Returns:



25
26
27
# File 'lib/active_graph/shared/type_converters.rb', line 25

def converted?(value)
  false
end

.db_typeObject



33
34
35
# File 'lib/active_graph/shared/type_converters.rb', line 33

def db_type
  Integer
end

.to_db(value) ⇒ Object



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

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



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

def to_ruby(value)
  value.to_i
end