Sha256: e114dcee5152581edfc20e29eefa96f55b730c3ee9e1e37c517c39532b8ceca1

Contents?: true

Size: 1.56 KB

Versions: 19

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

19 entries across 19 versions & 1 rubygems

Version Path
mutx-0.1.38 lib/mutx/custom/execution.rb
mutx-0.1.37 lib/mutx/custom/execution.rb
mutx-0.1.36 lib/mutx/custom/execution.rb
mutx-0.1.35 lib/mutx/custom/execution.rb
mutx-0.1.34 lib/mutx/custom/execution.rb
mutx-0.1.33 lib/mutx/custom/execution.rb
mutx-0.1.32 lib/mutx/custom/execution.rb
mutx-0.1.31 lib/mutx/custom/execution.rb
mutx-0.1.30 lib/mutx/custom/execution.rb
mutx-0.1.29 lib/mutx/custom/execution.rb
mutx-0.1.28 lib/mutx/custom/execution.rb
mutx-0.1.27 lib/mutx/custom/execution.rb
mutx-0.1.26 lib/mutx/custom/execution.rb
mutx-0.1.25 lib/mutx/custom/execution.rb
mutx-0.1.24 lib/mutx/custom/execution.rb
mutx-0.1.23 lib/mutx/custom/execution.rb
mutx-0.1.22 lib/mutx/custom/execution.rb
mutx-0.1.21 lib/mutx/custom/execution.rb
mutx-0.1.20 lib/mutx/custom/execution.rb