Class: Sunrise::Plugins
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Array
#chunk, #random, #shuffle, #shuffle!
Constructor Details
Returns a new instance of Plugins.
4
5
6
|
# File 'lib/sunrise/plugins.rb', line 4
def initialize
@plugins = []
end
|
Class Method Details
.activate(name) ⇒ Object
38
39
40
|
# File 'lib/sunrise/plugins.rb', line 38
def activate(name)
active << registered[name] if registered[name] && !active[name]
end
|
.active ⇒ Object
30
31
32
|
# File 'lib/sunrise/plugins.rb', line 30
def active
@active_plugins ||= self.new
end
|
.deactivate(name) ⇒ Object
42
43
44
|
# File 'lib/sunrise/plugins.rb', line 42
def deactivate(name)
active.delete_if {|p| p.name == name}
end
|
.registered ⇒ Object
34
35
36
|
# File 'lib/sunrise/plugins.rb', line 34
def registered
@registered_plugins ||= self.new
end
|
.set_active(names) ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/sunrise/plugins.rb', line 46
def set_active(names)
@active_plugins = self.new
names.each do |name|
activate(name)
end
end
|
Instance Method Details
#find_by_name(name) ⇒ Object
Also known as:
[]
8
9
10
|
# File 'lib/sunrise/plugins.rb', line 8
def find_by_name(name)
self.detect { |plugin| plugin.name == name.to_s.downcase }
end
|
#find_by_title(title) ⇒ Object
13
14
15
|
# File 'lib/sunrise/plugins.rb', line 13
def find_by_title(title)
self.detect { |plugin| plugin.title == title }
end
|
17
18
19
|
# File 'lib/sunrise/plugins.rb', line 17
def (value)
self.select { |p| p. == value.to_s.downcase }
end
|
#names ⇒ Object
21
22
23
|
# File 'lib/sunrise/plugins.rb', line 21
def names
self.map(&:name)
end
|
#titles ⇒ Object
25
26
27
|
# File 'lib/sunrise/plugins.rb', line 25
def titles
self.map(&:title)
end
|