Class: ActiveGraph::Shared::TypeConverters::YAMLConverter

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

Overview

Converts hash to/from YAML

Class Method Summary collapse

Methods inherited from BaseConverter

converted?, #supports_array?

Class Method Details

.convert_typeObject



231
232
233
# File 'lib/active_graph/shared/type_converters.rb', line 231

def convert_type
  Hash
end

.db_typeObject



235
236
237
# File 'lib/active_graph/shared/type_converters.rb', line 235

def db_type
  String
end

.to_db(value) ⇒ Object



239
240
241
# File 'lib/active_graph/shared/type_converters.rb', line 239

def to_db(value)
  Psych.dump(value)
end

.to_ruby(value) ⇒ Object



243
244
245
# File 'lib/active_graph/shared/type_converters.rb', line 243

def to_ruby(value)
  value.is_a?(Hash) ? value : Psych.load(value)
end