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

sets up new instance and initial configuration

Parameters:

  • group (String)

    name of the plugins group



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

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



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

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



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

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

#typesArray

Returns list of plugin types loaded.

Returns:

  • (Array)

    list of plugin types loaded



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

def types
  @plugins.keys
end