Class: Kaya::Custom::ExecutionData
- Inherits:
-
Object
- Object
- Kaya::Custom::ExecutionData
- Defined in:
- lib/kaya/custom/execution_data.rb
Class Method Summary collapse
-
.add(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
Class Method Details
.add(key = nil, value = nil) ⇒ Object
Stores a key => value pair to the result
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/kaya/custom/execution_data.rb', line 21 def self.add 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
42 43 44 45 |
# File 'lib/kaya/custom/execution_data.rb', line 42 def self.ensure_db_connection Kaya::Support::Configuration.get Kaya::Database::MongoConnector.new(Kaya::Support::Configuration.db_connection_data) unless Kaya::Database::MongoConnector.connected? end |
.get_data ⇒ Object
Returns result execution data if exist. Else returns an empty hash
37 38 39 |
# File 'lib/kaya/custom/execution_data.rb', line 37 def self.get_data self.is_there_result? ? self.get_result.execution_data : {} end |
.get_result ⇒ Object
32 33 34 |
# File 'lib/kaya/custom/execution_data.rb', line 32 def self.get_result Kaya::Results::Result.get(self.id) end |
.id ⇒ Object
Returns execution id
9 10 11 |
# File 'lib/kaya/custom/execution_data.rb', line 9 def self.id ENV["_id"] end |
.is_there_result? ⇒ Boolean
13 14 15 |
# File 'lib/kaya/custom/execution_data.rb', line 13 def self.is_there_result? Kaya::Database::MongoConnector.result_data_for_id(self.id) end |