# Creates a method that requires to be overridding. # If it not overridden and called upon a TypeError # will be raised. # # class C # abstract :a # end # # c = C.new # c.a #=> Error: undefined abstraction #a # class Module def abstract( *sym ) sym.each { |s| define_method( s ) { raise TypeError, "undefined abstraction ##{s}" } } end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCModule < Test::Unit::TestCase class Aq abstract :q end def test_001 ac = Aq.new assert_raises( TypeError ) { ac.q } end def test_002 ac = Class.new { abstract :q }.new assert_raises( TypeError ) { ac.q } end end =end