Class: Pluginator::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/pluginator/group.rb

Overview

Initial data for pluginator, includes group name and plugins

Direct Known Subclasses

Autodetect

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group) ⇒ Group

Returns a new instance of Group.

Parameters:

  • group (String)

    name of the plugins group



27
28
29
# File 'lib/pluginator/group.rb', line 27

def initialize(group)
  setup_group(group)
end

Instance Attribute Details

#groupObject (readonly)

Group name used for plugins



24
25
26
# File 'lib/pluginator/group.rb', line 24

def group
  @group
end

Instance Method Details

#[](type) ⇒ Array

Returns list of plugins for type.

Parameters:

  • type (String)

    of plugins to select

Returns:

  • (Array)

    list of plugins for type



33
34
35
# File 'lib/pluginator/group.rb', line 33

def [](type)
  @plugins[type.to_s]
end

#register_plugin(type, klass) ⇒ Object

Register a new plugin, can be used to load custom plugins

Parameters:

  • type (String)

    type for the klass

  • klass (Class)

    klass of the plugin to add



46
47
48
49
50
# File 'lib/pluginator/group.rb', line 46

def register_plugin(type, klass)
  type = type.to_s
  @plugins[type] ||= []
  @plugins[type].push(klass)
end

#typesArray

Returns list of plugin types loaded.

Returns:

  • (Array)

    list of plugin types loaded



38
39
40
# File 'lib/pluginator/group.rb', line 38

def types
  @plugins.keys
end