coffeescript で インターフェース の実装を強制する

クラス定義の中で@interfaceを宣言して@constructor.checkInterface()の呼び出しで実装されていないメソッドがあればエラーを発生させる。
……けどInterfaceクラスを継承させる必要があるので今一つ実用的でないか。

class Interface
	@interface: (interfaceClass) ->
		@ifList = 
			for method of interfaceClass::
				method if interfaceClass::hasOwnProperty(method)
	@checkInterface: ->
		for member in @ifList
			if @::hasOwnProperty(member) == false
				throw "interface not implemented: #{@name}.#{member}"

class ISample
	method1:->
	method2:->

class Sample1 extends Interface
	@interface ISample
	constructor: ->
		@constructor.checkInterface()
	method1: ->
	method2: ->

class Sample2 extends Interface
	@interface ISample
	constructor: ->
		@constructor.checkInterface()
	method1: ->

new Sample1()
new Sample2()