Class: Slugforge::SluginManager

Inherits:
Object
  • Object
show all
Defined in:
lib/slugforge/slugins.rb

Defined Under Namespace

Classes: NoSlugin, Slugin

Constant Summary collapse

PREFIX =
/^slugforge-/

Instance Method Summary collapse

Constructor Details

#initializeSluginManager

Returns a new instance of SluginManager.



83
84
85
86
# File 'lib/slugforge/slugins.rb', line 83

def initialize
  @slugins = []
  locate_slugins
end

Instance Method Details

#activate_slugins(config) ⇒ Object



103
104
105
# File 'lib/slugforge/slugins.rb', line 103

def activate_slugins(config)
  @slugins.each { |s| s.activate!(config) if s.enabled? }
end

#load_sluginsObject

Require all enabled slugins, disabled slugins are skipped.



99
100
101
# File 'lib/slugforge/slugins.rb', line 99

def load_slugins
  @slugins.each(&:load!)
end

#sluginsHash

Returns A hash with all slugin names (minus the prefix) as keys and slugin objects as values.

Returns:

  • (Hash)

    A hash with all slugin names (minus the prefix) as keys and slugin objects as values.



90
91
92
93
94
95
96
# File 'lib/slugforge/slugins.rb', line 90

def slugins
  h = Hash.new { |_, key| NoSlugin.new(key) }
  @slugins.each do |slugin|
    h[slugin.name] = slugin
  end
  h
end