Class: Mumukit::Runtime

Inherits:
Object
  • Object
show all
Includes:
RuntimeInfo, RuntimeShortcuts
Defined in:
lib/mumukit/runtime/runtime.rb

Instance Method Summary collapse

Methods included from RuntimeInfo

#info

Methods included from RuntimeShortcuts

#method_missing

Constructor Details

#initialize(config) ⇒ Runtime

Returns a new instance of Runtime.



5
6
7
8
# File 'lib/mumukit/runtime/runtime.rb', line 5

def initialize(config)
  @config = config
  @hook_classes = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Mumukit::RuntimeShortcuts

Instance Method Details

#hook_class(hook_name) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/mumukit/runtime/runtime.rb', line 28

def hook_class(hook_name)
  @hook_classes[hook_name] ||=
      if hook_defined? hook_name
        hook_name.to_mumukit_hook_class
      else
        hook_name.to_default_mumukit_hook_class
      end
end

#hook_defined?(hook_name) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/mumukit/runtime/runtime.rb', line 14

def hook_defined?(hook_name)
  hook_name.to_default_mumukit_hook_class rescue raise "Wrong hook #{hook_name}"

  Kernel.const_defined? hook_name.to_mumukit_hook_class_name
end

#hook_includes?(hook_name, mixin) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/mumukit/runtime/runtime.rb', line 20

def hook_includes?(hook_name, mixin)
  hook_class(hook_name).included_modules.include?(mixin)
end

#new_hook(hook_name) ⇒ Object



24
25
26
# File 'lib/mumukit/runtime/runtime.rb', line 24

def new_hook(hook_name)
  hook_class(hook_name).new(@config)
end

#reset!Object



10
11
12
# File 'lib/mumukit/runtime/runtime.rb', line 10

def reset!
  @hook_classes = {}
end