Class: Diggit::Runnable Abstract
Overview
Abstract superclass for analysis and joins.
Base class for analyses and joins. Runnables can be runned or cleaned. These methods have to be implemented in the subclasses. Addons can be made available to a runnable through a call to Runnable.require_addons. Addons can be accessed through the addons attribute, and they contain automatically methods that has names of their addons.
Instance Attribute Summary collapse
-
#addons ⇒ Hash<String, Addon>
readonly
The hash of addons.
Attributes inherited from Plugin
Class Method Summary collapse
-
.require_addons(*names) ⇒ void
Add an addon as a required addon.
- .required_addons ⇒ Object
Instance Method Summary collapse
-
#clean ⇒ void
abstract
Clean the runnable.
-
#initialize(options) ⇒ Runnable
constructor
A new instance of Runnable.
-
#run ⇒ void
abstract
Run the runnable.
Methods inherited from Plugin
Constructor Details
#initialize(options) ⇒ Runnable
Returns a new instance of Runnable.
63 64 65 66 67 68 |
# File 'lib/dgit/plugins.rb', line 63 def initialize() super() @addons = {} self.class.required_addons.each { |a| @addons[a] = Dig.it.plugin_loader.load_plugin(a, :addon, true) } @addons.each_key { |a| self.class.class_eval { define_method(a) { return @addons[a] } } } end |
Instance Attribute Details
#addons ⇒ Hash<String, Addon> (readonly)
Returns the hash of addons.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/dgit/plugins.rb', line 60 class Runnable < Plugin attr_reader :addons def initialize() super() @addons = {} self.class.required_addons.each { |a| @addons[a] = Dig.it.plugin_loader.load_plugin(a, :addon, true) } @addons.each_key { |a| self.class.class_eval { define_method(a) { return @addons[a] } } } end # Run the runnable. # @abstract This method must be overrided. # @return [void] def run end # Clean the runnable. # @abstract This method must be overrided. # @return [void] def clean end # Add an addon as a required addon. # # @param names Array<String> the names of addons to require. # They correspond to the name of their class with underscore case. # @return [void] def self.require_addons(*names) @required_addons = names end def self.required_addons return [] if @required_addons.nil? @required_addons end end |
Class Method Details
.require_addons(*names) ⇒ void
This method returns an undefined value.
Add an addon as a required addon.
87 88 89 |
# File 'lib/dgit/plugins.rb', line 87 def self.require_addons(*names) @required_addons = names end |
.required_addons ⇒ Object
91 92 93 94 |
# File 'lib/dgit/plugins.rb', line 91 def self.required_addons return [] if @required_addons.nil? @required_addons end |
Instance Method Details
#clean ⇒ void
This method must be overrided.
This method returns an undefined value.
Clean the runnable.
79 80 |
# File 'lib/dgit/plugins.rb', line 79 def clean end |
#run ⇒ void
This method must be overrided.
This method returns an undefined value.
Run the runnable.
73 74 |
# File 'lib/dgit/plugins.rb', line 73 def run end |