Skip to content

Instantly share code, notes, and snippets.

@tensiondriven
Created October 12, 2013 01:10
Show Gist options
  • Save tensiondriven/6944426 to your computer and use it in GitHub Desktop.
Save tensiondriven/6944426 to your computer and use it in GitHub Desktop.
Store a model in a Mongoid field using YAML
class YamlType
def mongoize
YAML.dump(object)
end
class << self
def mongoize(object)
YAML.dump(object)
end
def demongoize(object)
YAML.load(object)
end
def evolve(object)
case object
when String, Regex
object
else
object.mongoize
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment