Skip to content

Instantly share code, notes, and snippets.

@kke
Created January 23, 2012 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kke/1661748 to your computer and use it in GitHub Desktop.
Save kke/1661748 to your computer and use it in GitHub Desktop.
class User
include Mongoid::Document
alias_method :name_orig, :name
def name
class << self
alias_method :name, :name_orig
end
self[:name].nil? ? self[:name] = Name.new : self[:name]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment