Class: Module

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

Instance Method Summary collapse

Instance Method Details

#as_moduleObject



22
23
24
# File 'lib/mumukit/core/modulability.rb', line 22

def as_module
  self
end

#as_module_nameObject



26
27
28
# File 'lib/mumukit/core/modulability.rb', line 26

def as_module_name
  name
end

#like?(other) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/mumukit/core/likeability.rb', line 8

def like?(other)
  super || to_s.underscore == other.to_s
end

#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