Class: Module

Inherits:
Object show all
Defined in:
lib/mumukit/core/module.rb

Instance Method Summary collapse

Instance Method Details

#patch(method_name, &block) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/mumukit/core/module.rb', line 9

def patch(method_name, &block)
  method_proc = instance_method method_name

  define_method method_name do |*args|
    instance_exec(*args, method_proc.bind(self), &block)
  end
end

#required(name, message = nil) ⇒ Object



2
3
4
5
6
7
# File 'lib/mumukit/core/module.rb', line 2

def required(name, message=nil)
  message ||= "You need to implement method #{name}"
  define_method name do |*|
    raise message
  end
end