Class: Module
Overview
lib/ruby/module.rb
Instance Method Summary collapse
-
#abstract(name, *params) ⇒ void
Creates an abstract method.
- #def_delegators(target, *methods) ⇒ Object
Instance Method Details
#abstract(name, *params) ⇒ void
This method returns an undefined value.
Creates an abstract method
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/ruby/jruby_hack.rb', line 322 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 |
#def_delegators(target, *methods) ⇒ Object
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/ruby/jruby_hack.rb', line 347 def def_delegators(target, *methods) file, line, = Stupidedi.caller for m in methods if m.to_s =~ /=$/ class_eval(<<-RUBY, file, line.to_i - 1) def #{m}(value) #{target}.#{m}(value) end RUBY else class_eval(<<-RUBY, file, line.to_i - 1) def #{m}(*args, &block) #{target}.#{m}(*args, &block) end RUBY end end end |