Class: Sappho::ModuleRegister

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/sappho-basics/module_register.rb

Instance Method Summary collapse

Constructor Details

#initializeModuleRegister

Returns a new instance of ModuleRegister.



15
16
17
# File 'lib/sappho-basics/module_register.rb', line 15

def initialize
  @modules = { :log => AutoFlushLog.instance }
end

Instance Method Details

#eachObject



35
36
37
38
39
40
41
42
43
# File 'lib/sappho-basics/module_register.rb', line 35

def each
  @modules.each do |name, mod|
    begin
      yield mod
    rescue
      # do nothing here - modules must report if they need to
    end
  end
end

#get(name) ⇒ Object



23
24
25
# File 'lib/sappho-basics/module_register.rb', line 23

def get name
  @modules[name]
end

#set(name, mod) ⇒ Object



19
20
21
# File 'lib/sappho-basics/module_register.rb', line 19

def set name, mod
  @modules[name] = mod
end

#set?(name) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/sappho-basics/module_register.rb', line 27

def set? name
  @modules.has_key? name
end

#shutdownObject



31
32
33
# File 'lib/sappho-basics/module_register.rb', line 31

def shutdown
  each { |mod| mod.shutdown }
end