Created
March 5, 2009 17:55
-
-
Save Peeja/74463 to your computer and use it in GitHub Desktop.
Enforced abstract class in Ruby. Handy for refactoring.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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