class Xeme::Transaction

An object of this class provides meta information about the request and results. It always provides a timestamp and a unique ID for the results. It may also optionally include a request ID that was provided by the process that made the request, such as a call to a REST application. Do not directly instantiate this class; use Xeme#transaction.

Attributes

request[RW]

Optional. An ID for the request that was sent by the calling process. Do not generate this value yourself; use the ID that was sent with the request (if one was sent).

response[RW]

Gives a unique ID for these results.

timestamp[RW]

Gives a timestamp for when these results were generated.

Public Class Methods

new() click to toggle source

Initialize does not take any parameters.

# File lib/xeme.rb, line 602
def initialize
        @timestamp = DateTime.now()
        @response = rand().to_s.sub(/\A0\./mu, '')
        @request = nil
end

Public Instance Methods

to_h() click to toggle source
# File lib/xeme.rb, line 615
def to_h
        rv = {}
        
        # request
        if @request
                rv['request'] = @request
        end
        
        # response and timestamp
        rv['response'] = @response
        rv['timestamp'] = @timestamp.to_s
        
        # return
        return rv
end