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



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

def convert_type
  Hash
end

.db_typeObject



271
272
273
# File 'lib/active_graph/shared/type_converters.rb', line 271

def db_type
  String
end

.to_db(value) ⇒ Object



275
276
277
# File 'lib/active_graph/shared/type_converters.rb', line 275

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

.to_ruby(value) ⇒ Object



279
280
281
# File 'lib/active_graph/shared/type_converters.rb', line 279

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