Skip to content

Instantly share code, notes, and snippets.

@Peeja
Created March 5, 2009 17:55
Show Gist options
  • Save Peeja/74463 to your computer and use it in GitHub Desktop.
Save Peeja/74463 to your computer and use it in GitHub Desktop.
Enforced abstract class in Ruby. Handy for refactoring.
class User < ActiveRecord::Base
# This is begging to be a plugin, or even a gem.
def self.new(*_)
raise "Code is an abstract class and cannot be instantiated" if self == User
super
end
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment