Class: Mutx::Custom::Execution
- Inherits:
-
Object
- Object
- Mutx::Custom::Execution
- Defined in:
- lib/mutx/custom/execution.rb
Class Method Summary collapse
-
.add_data(key = nil, value = nil) ⇒ Object
Stores a key => value pair to the result.
-
.ensure_db_connection ⇒ Object
Conntects to database if not connected.
-
.get_data ⇒ Object
Returns result execution data if exist.
- .get_result ⇒ Object
-
.id ⇒ Object
Returns execution id.
- .is_there_result? ⇒ Boolean
-
.output_path ⇒ Object
This class is used from execution code.
Class Method Details
.add_data(key = nil, value = nil) ⇒ Object
Stores a key => value pair to the result
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mutx/custom/execution.rb', line 26 def self.add_data key=nil, value=nil self.ensure_db_connection if self.is_there_result? result = self.get_result if result and result.running? result.add_execution_data key, value if key {key => value} end end end |
.ensure_db_connection ⇒ Object
Conntects to database if not connected
47 48 49 50 |
# File 'lib/mutx/custom/execution.rb', line 47 def self.ensure_db_connection Mutx::Support::Configuration.get Mutx::Database::MongoConnector.new(Mutx::Support::Configuration.db_connection_data) unless Mutx::Database::MongoConnector.connected? end |
.get_data ⇒ Object
Returns result execution data if exist. Else returns an empty hash
42 43 44 |
# File 'lib/mutx/custom/execution.rb', line 42 def self.get_data self.is_there_result? ? self.get_result.execution_data : {} end |
.get_result ⇒ Object
37 38 39 |
# File 'lib/mutx/custom/execution.rb', line 37 def self.get_result Mutx::Results::Result.get(self.id) end |
.id ⇒ Object
Returns execution id
14 15 16 |
# File 'lib/mutx/custom/execution.rb', line 14 def self.id ENV["_id"] end |
.is_there_result? ⇒ Boolean
18 19 20 |
# File 'lib/mutx/custom/execution.rb', line 18 def self.is_there_result? Mutx::Database::MongoConnector.result_data_for_id(self.id) end |
.output_path ⇒ Object
This class is used from execution code. It means that user can call this method to store information during exdecution.
9 10 11 |
# File 'lib/mutx/custom/execution.rb', line 9 def self.output_path "#{Dir.pwd}/mutx/out/ENV['_id']" end |