Class: ActiveGraph::Shared::TypeConverters::JSONConverter

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

Overview

Converts hash to/from JSON

Class Method Summary collapse

Methods inherited from BaseConverter

#supports_array?

Class Method Details

.convert_typeObject



256
257
258
# File 'lib/active_graph/shared/type_converters.rb', line 256

def convert_type
  JSON
end

.converted?(_value) ⇒ Boolean

Returns:



252
253
254
# File 'lib/active_graph/shared/type_converters.rb', line 252

def converted?(_value)
  false
end

.db_typeObject



260
261
262
# File 'lib/active_graph/shared/type_converters.rb', line 260

def db_type
  String
end

.to_db(value) ⇒ Object



264
265
266
# File 'lib/active_graph/shared/type_converters.rb', line 264

def to_db(value)
  value.to_json
end

.to_ruby(value) ⇒ Object



268
269
270
# File 'lib/active_graph/shared/type_converters.rb', line 268

def to_ruby(value)
  JSON.parse(value, quirks_mode: true)
end