Class: Refinery::Plugins

Inherits:
Array
  • Object
show all
Defined in:
core/lib/refinery/plugins.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) activate(name)



47
48
49
# File 'core/lib/refinery/plugins.rb', line 47

def activate(name)
  active << registered[name] if registered[name] && !active[name]
end

+ (Object) active



35
36
37
# File 'core/lib/refinery/plugins.rb', line 35

def active
  @active_plugins ||= new
end

+ (Object) always_allowed



39
40
41
# File 'core/lib/refinery/plugins.rb', line 39

def always_allowed
  new registered.select(&:always_allow_access)
end

+ (Object) deactivate(name)



51
52
53
# File 'core/lib/refinery/plugins.rb', line 51

def deactivate(name)
  active.delete_if {|p| p.name == name}
end

+ (Object) registered



43
44
45
# File 'core/lib/refinery/plugins.rb', line 43

def registered
  @registered_plugins ||= new
end

+ (Object) set_active(names)



55
56
57
58
59
60
61
# File 'core/lib/refinery/plugins.rb', line 55

def set_active(names)
  @active_plugins = new

  names.each do |name|
    activate(name)
  end
end

Instance Method Details

- (Object) find_by_model(model)



4
5
6
7
# File 'core/lib/refinery/plugins.rb', line 4

def find_by_model(model)
  model = model.constantize if model.is_a? String
  detect { |plugin| plugin.activity.any? {|activity| activity.klass == model } }
end

- (Object) find_by_name(name) Also known as: []



9
10
11
# File 'core/lib/refinery/plugins.rb', line 9

def find_by_name(name)
  detect { |plugin| plugin.name == name }
end

- (Object) find_by_title(title)



14
15
16
# File 'core/lib/refinery/plugins.rb', line 14

def find_by_title(title)
  detect { |plugin| plugin.title == title }
end

- (Object) in_menu



18
19
20
# File 'core/lib/refinery/plugins.rb', line 18

def in_menu
  self.class.new(reject(&:hide_from_menu))
end

- (Object) names



22
23
24
# File 'core/lib/refinery/plugins.rb', line 22

def names
  map(&:name)
end

- (Object) pathnames



26
27
28
# File 'core/lib/refinery/plugins.rb', line 26

def pathnames
  map(&:pathname).compact.uniq
end

- (Object) titles



30
31
32
# File 'core/lib/refinery/plugins.rb', line 30

def titles
  map(&:title)
end