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_BACKEND =
Object.new.freeze
DEFAULT_COMMAND =
Object.new.freeze

Class Method Summary collapse

Class Method Details

.action_hook(&block) ⇒ Object



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

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

.action_hooksObject



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

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

.backend(type, &block) ⇒ Object



54
55
56
57
# File 'lib/yle_tf/plugin.rb', line 54

def self.backend(type, &block)
  type = type.to_s if type.is_a?(Symbol)
  backends[type] = block
end

.backendsObject



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

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

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



32
33
34
35
36
37
38
# File 'lib/yle_tf/plugin.rb', line 32

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

.commandsObject



28
29
30
# File 'lib/yle_tf/plugin.rb', line 28

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

.config_context(context = nil) ⇒ Object



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

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

.default_config(config = nil) ⇒ Object



40
41
42
43
# File 'lib/yle_tf/plugin.rb', line 40

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

.managerObject



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

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

.registerObject



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

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