Module: Mongo::Model::AttributeConvertors

Defined in:
lib/mongo_db/model/attribute_convertors.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

CONVERTORS =
{
  line: {
    from_string: -> s {(s || "").split(',').collect{|s| s.strip}},
    to_string:   -> v {v.join(', ')}
  },
  column: {
    from_string: -> s {(s || "").split("\n").collect{|s| s.strip}},
    to_string:   -> v {v.join("\n")}
  },
  yaml: {
    from_string: -> s {YAML.load s rescue {}},
    to_string:   -> v {v.to_yaml.strip}
  },
  json: {
    from_string: -> s {JSON.parse s rescue {}},
    to_string:   -> v {v.to_json.strip}
  }
}