Module: AbstractClass

Overview

A module used for making abstract classes. Any class that includes this module will not be able to be instantiated directly.

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

Callback method for when this module is included.

Parameters:

  • klass (Class)

    The Class object for the including class.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rltk/util/abstract_class.rb', line 12

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