Skip to content

Instantly share code, notes, and snippets.

@chriswailes
Created April 20, 2012 23:47
Show Gist options
  • Save chriswailes/2432710 to your computer and use it in GitHub Desktop.
Save chriswailes/2432710 to your computer and use it in GitHub Desktop.
Abstract Class implementation for Ruby
module AbstractClass
def self.included(klass)
klass.instance_exec do
@abstract_class = klass
def self.new(*args)
if self == @abstract_class
raise "Instantiating abstract class #{self} is not allowed."
else
super
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment