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



250
251
252
# File 'lib/active_graph/shared/type_converters.rb', line 250

def convert_type
  JSON
end

.converted?(_value) ⇒ Boolean

Returns:



246
247
248
# File 'lib/active_graph/shared/type_converters.rb', line 246

def converted?(_value)
  false
end

.db_typeObject



254
255
256
# File 'lib/active_graph/shared/type_converters.rb', line 254

def db_type
  String
end

.to_db(value) ⇒ Object



258
259
260
# File 'lib/active_graph/shared/type_converters.rb', line 258

def to_db(value)
  value.to_json
end

.to_ruby(value) ⇒ Object



262
263
264
# File 'lib/active_graph/shared/type_converters.rb', line 262

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