Module: Mongoid::AttributeConvertors
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/mongoid_misc/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 { # Mongoid uses it's internal Hash that doesn't support to_yaml hash = {}; v.each{|k, v| hash[k] = v} hash.to_yaml.strip } }, json: { from_string: -> s {JSON.parse s rescue {}}, to_string: -> v { # Mongoid uses it's internal Hash that doesn't support to_yaml hash = {}; v.each{|k, v| hash[k] = v} hash.to_json.strip } } }