Class: YleTf::Plugin

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

Defined Under Namespace

Modules: Loader Classes: ActionHook, Manager

Constant Summary collapse

DEFAULT_COMMAND =
Object.new.freeze

Class Method Summary collapse

Class Method Details

.action_hook(&block) ⇒ Object



21
22
23
# File 'lib/yle_tf/plugin.rb', line 21

def self.action_hook(&block)
  action_hooks << block
end

.action_hooksObject



17
18
19
# File 'lib/yle_tf/plugin.rb', line 17

def self.action_hooks
  @action_hooks ||= []
end

.backend(type, &block) ⇒ Object



51
52
53
# File 'lib/yle_tf/plugin.rb', line 51

def self.backend(type, &block)
  backends[type.to_sym] = block
end

.backendsObject



47
48
49
# File 'lib/yle_tf/plugin.rb', line 47

def self.backends
  @backends ||= {}
end

.command(name, synopsis, &block) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/yle_tf/plugin.rb', line 29

def self.command(name, synopsis, &block)
  name = name.to_s if name.is_a?(Symbol)
  commands[name] = {
    synopsis: synopsis,
    proc: block
  }
end

.commandsObject



25
26
27
# File 'lib/yle_tf/plugin.rb', line 25

def self.commands
  @commands ||= {}
end

.config_context(context = nil) ⇒ Object



42
43
44
45
# File 'lib/yle_tf/plugin.rb', line 42

def self.config_context(context = nil)
  @config_context = context if context
  @config_context || {}
end

.default_config(config = nil) ⇒ Object



37
38
39
40
# File 'lib/yle_tf/plugin.rb', line 37

def self.default_config(config = nil)
  @default_config = config if config
  @default_config || {}
end

.managerObject



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

def self.manager
  @manager ||= Manager.new
end

.registerObject



13
14
15
# File 'lib/yle_tf/plugin.rb', line 13

def self.register
  Plugin.manager.register(self)
end