Skip to content

Instantly share code, notes, and snippets.

@banker
Created January 15, 2009 18:06
Show Gist options
  • Save banker/47510 to your computer and use it in GitHub Desktop.
Save banker/47510 to your computer and use it in GitHub Desktop.
# Dynamically create a subclass in rails.
def create_subclass(class_name, subclass=nil)
name = class_name.to_s.camelize
Object.const_set(name, Class.new(CryptedAttribute))
end
create_subclass(:username, CryptedAttribute)
=> Username
Username.superclass
=> CryptedAttribute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment