Class: Danger::Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/danger/plugin_support/plugin.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dangerfile) ⇒ Plugin

Returns a new instance of Plugin.



3
4
5
# File 'lib/danger/plugin_support/plugin.rb', line 3

def initialize(dangerfile)
  @dangerfile = dangerfile
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object

Since we have a reference to the Dangerfile containing all the information We need to redirect the self calls to the Dangerfile



20
21
22
# File 'lib/danger/plugin_support/plugin.rb', line 20

def method_missing(method_sym, *arguments, &block)
  @dangerfile.send(method_sym, *arguments, &block)
end

Class Method Details

.all_pluginsObject



24
25
26
# File 'lib/danger/plugin_support/plugin.rb', line 24

def self.all_plugins
  @all_plugins ||= []
end

.clear_external_pluginsObject



28
29
30
# File 'lib/danger/plugin_support/plugin.rb', line 28

def self.clear_external_plugins
  @all_plugins = @all_plugins.select { |plugin| Dangerfile.core_plugin_classes.include? plugin }
end

.inherited(plugin) ⇒ Object



32
33
34
# File 'lib/danger/plugin_support/plugin.rb', line 32

def self.inherited(plugin)
  Plugin.all_plugins.push(plugin)
end

.instance_nameObject



7
8
9
# File 'lib/danger/plugin_support/plugin.rb', line 7

def self.instance_name
  to_s.gsub("Danger", "").danger_underscore.split('/').last
end