class Opener::Webservice::Transaction

Class for storing information of a single transaction in a thread.

@!attribute [r] parameters

@return [Hash]

Constants

THREAD_KEY

The name of the key to store the current transaction in.

@return [Symbol]

Attributes

parameters[R]

Public Class Methods

current() click to toggle source

Returns the current transaction.

@return [Opener::Daemons::Transaction]

# File lib/opener/webservice/transaction.rb, line 24
def self.current
  return Thread.current[THREAD_KEY] ||= new
end
new() click to toggle source
# File lib/opener/webservice/transaction.rb, line 35
def initialize
  @parameters = {}
end
reset_current() click to toggle source

Removes the current transaction

# File lib/opener/webservice/transaction.rb, line 31
def self.reset_current
  Thread.current[THREAD_KEY] = nil
end

Public Instance Methods

add_parameters(parameters = {}) click to toggle source

Merges the given parameters with the existing ones.

If New Relic is enabled the parameters are also added to the current New Relic transaction.

@param [Hash] parameters

# File lib/opener/webservice/transaction.rb, line 47
def add_parameters(parameters = {})
  @parameters = @parameters.merge(parameters)

  if Configuration.newrelic?
    NewRelic::Agent.add_custom_parameters(parameters)
  end
end