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



225
226
227
# File 'lib/active_graph/shared/type_converters.rb', line 225

def convert_type
  Hash
end

.db_typeObject



229
230
231
# File 'lib/active_graph/shared/type_converters.rb', line 229

def db_type
  String
end

.to_db(value) ⇒ Object



233
234
235
# File 'lib/active_graph/shared/type_converters.rb', line 233

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

.to_ruby(value) ⇒ Object



237
238
239
# File 'lib/active_graph/shared/type_converters.rb', line 237

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