Skip to content

Instantly share code, notes, and snippets.

@kke
Created January 23, 2012 08:29
Show Gist options
  • Select an option

  • Save kke/1661748 to your computer and use it in GitHub Desktop.

Select an option

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