Class: Module
Instance Method Summary collapse
-
#abstract(name, *params) ⇒ void
Creates an abstract method.
Instance Method Details
#abstract(name, *params) ⇒ void
This method returns an undefined value.
Creates an abstract method
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ruby/module.rb', line 12 def abstract(name, *params) if params.last.is_a?(Hash) # abstract :method, :args => %w(a b c) params = params.last[:args] end file, line, = Stupidedi.caller if params.empty? class_eval(<<-RUBY, file, line.to_i - 1) def #{name}(*args) raise NoMethodError, "method \#{self.class.name}.#{name} is abstract" end RUBY else class_eval(<<-RUBY, file, line.to_i - 1) def #{name}(*args) raise NoMethodError, "method \#{self.class.name}.#{name}(#{params.join(', ')}) is abstract" end RUBY end end |