Class: YleTf::Plugin::Manager
- Inherits:
-
Object
- Object
- YleTf::Plugin::Manager
- Defined in:
- lib/yle_tf/plugin/manager.rb
Instance Attribute Summary collapse
-
#registered ⇒ Object
readonly
Returns the value of attribute registered.
Instance Method Summary collapse
- #action_hooks ⇒ Object
- #backends ⇒ Object
- #commands ⇒ Object
- #config_contexts ⇒ Object
- #default_configs ⇒ Object
-
#initialize ⇒ Manager
constructor
A new instance of Manager.
- #register(plugin) ⇒ Object
Constructor Details
#initialize ⇒ Manager
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
#registered ⇒ Object (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_hooks ⇒ Object
19 20 21 |
# File 'lib/yle_tf/plugin/manager.rb', line 19 def action_hooks registered.map(&:action_hooks).flatten end |
#backends ⇒ Object
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 |
#commands ⇒ Object
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_contexts ⇒ Object
32 33 34 |
# File 'lib/yle_tf/plugin/manager.rb', line 32 def config_contexts registered.map(&:config_context) end |
#default_configs ⇒ Object
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 |