Sha256: be1ff9b495882699f634450a6e96011815500447c545a60e15e761f1dc995f2b

Contents?: true

Size: 1.56 KB

Versions: 30

Compression:

Stored size: 1.56 KB

Contents

# encoding: utf-8
module Mutx
  module Custom
    class Execution

      # This class is used from execution code. It means that user can call this method to store information
      # during exdecution.
      #
      def self.output_path
        "#{Dir.pwd}/mutx/out/ENV['_id']"
      end

      # Returns execution id
      def self.id
        ENV["_id"]
      end

      def self.is_there_result?
        Mutx::Database::MongoConnector.result_data_for_id(self.id)
      end

      # Stores a key => value pair to the result
      # @param [String or Symbol] key
      # @param [Any] value
      # @return hash if stored, nil if not
      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
        ##Mutx::Database::MongoConnector.force_close
      end

      def self.get_result
        Mutx::Results::Result.get(self.id)
      end

      # Returns result execution data if exist. Else returns an empty hash
      def self.get_data
        self.is_there_result? ? self.get_result.execution_data : {}
        ##Mutx::Database::MongoConnector.force_close
      end

      # Conntects to database if not connected
      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


    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
mutx-0.1.69 lib/mutx/custom/execution.rb
mutx-0.1.68 lib/mutx/custom/execution.rb
mutx-0.1.67 lib/mutx/custom/execution.rb
mutx-0.1.66 lib/mutx/custom/execution.rb
mutx-0.1.65 lib/mutx/custom/execution.rb
mutx-0.1.64 lib/mutx/custom/execution.rb
mutx-0.1.63 lib/mutx/custom/execution.rb
mutx-0.1.62 lib/mutx/custom/execution.rb
mutx-0.1.61 lib/mutx/custom/execution.rb
mutx-0.1.60 lib/mutx/custom/execution.rb
mutx-0.1.59 lib/mutx/custom/execution.rb
mutx-0.1.58 lib/mutx/custom/execution.rb
mutx-0.1.57 lib/mutx/custom/execution.rb
mutx-0.1.56 lib/mutx/custom/execution.rb
mutx-0.1.55 lib/mutx/custom/execution.rb
mutx-0.1.54 lib/mutx/custom/execution.rb
mutx-0.1.53 lib/mutx/custom/execution.rb
mutx-0.1.52 lib/mutx/custom/execution.rb
mutx-0.1.51 lib/mutx/custom/execution.rb
mutx-0.1.50 lib/mutx/custom/execution.rb