Class: Danger::Plugin
- Inherits:
-
Object
- Object
- Danger::Plugin
- Defined in:
- lib/danger/plugin_support/plugin.rb
Direct Known Subclasses
DangerfileGitHubPlugin, DangerfileGitPlugin, DangerfileImportPlugin, DangerfileMessagingPlugin
Class Method Summary collapse
Instance Method Summary collapse
- #fail(*args, &blk) ⇒ Object
-
#initialize(dangerfile) ⇒ Plugin
constructor
A new instance of Plugin.
-
#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.
-
#warn(*args, &blk) ⇒ Object
Both of these methods exist on all objects ruby-doc.org/core-2.2.3/Kernel.html#method-i-warn ruby-doc.org/core-2.2.3/Kernel.html#method-i-fail However, as we’re using using them in the DSL, they won’t get method_missing called correctly.
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
27 28 29 |
# File 'lib/danger/plugin_support/plugin.rb', line 27 def method_missing(method_sym, *arguments, &_block) @dangerfile.send(method_sym, *arguments) end |
Class Method Details
.instance_name ⇒ Object
7 8 9 |
# File 'lib/danger/plugin_support/plugin.rb', line 7 def self.instance_name self.to_s.gsub("Danger", "").danger_underscore.split('/').last end |
Instance Method Details
#fail(*args, &blk) ⇒ Object
21 22 23 |
# File 'lib/danger/plugin_support/plugin.rb', line 21 def fail(*args, &blk) method_missing(:fail, *args, &blk) end |
#warn(*args, &blk) ⇒ Object
Both of these methods exist on all objects ruby-doc.org/core-2.2.3/Kernel.html#method-i-warn ruby-doc.org/core-2.2.3/Kernel.html#method-i-fail However, as we’re using using them in the DSL, they won’t get method_missing called correctly.
17 18 19 |
# File 'lib/danger/plugin_support/plugin.rb', line 17 def warn(*args, &blk) method_missing(:warn, *args, &blk) end |