Module: MongoMapper::Plugins::Serialization::ClassMethods

Defined in:
lib/mongo_mapper/plugins/serialization.rb

Instance Method Summary collapse

Instance Method Details

#from_json(json) ⇒ Object



75
76
77
# File 'lib/mongo_mapper/plugins/serialization.rb', line 75

def from_json(json)
  self.new(ActiveSupport::JSON.decode(json))
end

#from_xml(xml) ⇒ Object



79
80
81
82
83
84
# File 'lib/mongo_mapper/plugins/serialization.rb', line 79

def from_xml(xml)
  # instance = self.new
  # instance.attributes = self.new
  # instance
  instance.attributes = self.new(Hash.from_xml(xml).values.first)
end