| Module | Abstract |
| In: |
lib/abstract.rb
|
# File lib/abstract.rb, line 19 def self.included(klass) super if klass.include?(Concrete) raise(TypeError, "#{klass} - cannot make abstract a concrete class") end klass.module_eval do class << self unless private_method_defined?(:concrete_new) alias_method :concrete_new, :new visibility = instance_method_visibility('new') def new(*args, &block) raise(TypeError, "cannot instantiate an abstract class #{name}") end send(visibility, :new) private :concrete_new end end end end