Class: Diggit::Runnable Abstract
Overview
Abstract superclass for analysis and joins.
Base class for analyses and joins. Runnables can be runned or cleaned. A clean of a runnable should always work, even if it has never been run. 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.
76 77 78 79 80 81 |
# File 'lib/dgit/plugins.rb', line 76 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.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/dgit/plugins.rb', line 73 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 base_addons = superclass < Runnable ? superclass.required_addons : [] return base_addons if @required_addons.nil? base_addons + @required_addons end end |
Class Method Details
.require_addons(*names) ⇒ void
This method returns an undefined value.
Add an addon as a required addon.
98 99 100 |
# File 'lib/dgit/plugins.rb', line 98 def self.require_addons(*names) @required_addons = names end |
.required_addons ⇒ Object
102 103 104 105 106 |
# File 'lib/dgit/plugins.rb', line 102 def self.required_addons base_addons = superclass < Runnable ? superclass.required_addons : [] return base_addons if @required_addons.nil? base_addons + @required_addons end |
Instance Method Details
#clean ⇒ void
This method must be overrided.
This method returns an undefined value.
Clean the runnable.
91 |
# File 'lib/dgit/plugins.rb', line 91 def clean; end |
#run ⇒ void
This method must be overrided.
This method returns an undefined value.
Run the runnable.
86 |
# File 'lib/dgit/plugins.rb', line 86 def run; end |