Class: YleTf::Plugin::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/yle_tf/plugin/manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeManager

Returns a new instance of Manager.



8
9
10
# File 'lib/yle_tf/plugin/manager.rb', line 8

def initialize
  @registered = []
end

Instance Attribute Details

#registeredObject (readonly)

Returns the value of attribute registered.



6
7
8
# File 'lib/yle_tf/plugin/manager.rb', line 6

def registered
  @registered
end

Instance Method Details

#action_hooksObject



19
20
21
# File 'lib/yle_tf/plugin/manager.rb', line 19

def action_hooks
  registered.map(&:action_hooks).flatten
end

#backendsObject



40
41
42
43
44
45
46
# File 'lib/yle_tf/plugin/manager.rb', line 40

def backends
  {}.tap do |backends|
    registered.each do |plugin|
      backends.merge!(plugin.backends)
    end
  end
end

#commandsObject



23
24
25
26
27
28
29
30
# File 'lib/yle_tf/plugin/manager.rb', line 23

def commands
  {}.tap do |commands|
    registered.each do |plugin|
      commands.merge!(plugin.commands)
    end
    commands.default = commands.delete(DEFAULT_COMMAND)
  end
end

#config_contextsObject



32
33
34
# File 'lib/yle_tf/plugin/manager.rb', line 32

def config_contexts
  registered.map(&:config_context)
end

#default_configsObject



36
37
38
# File 'lib/yle_tf/plugin/manager.rb', line 36

def default_configs
  registered.map(&:default_config)
end

#register(plugin) ⇒ Object



12
13
14
15
16
17
# File 'lib/yle_tf/plugin/manager.rb', line 12

def register(plugin)
  if !registered.include?(plugin)
    Logger.debug("Registered plugin: #{plugin}")
    @registered << plugin
  end
end