Class: Xeme::Transaction
- Inherits:
-
Object
- Object
- Xeme::Transaction
- Defined in:
- lib/xeme.rb
Overview
An object of this class provdes meta information about the request and results. It always provides a 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.
Instance Attribute Summary collapse
-
#request ⇒ Object
Optional.
-
#response ⇒ Object
readonly
Gives a unique ID for these results.
-
#timestamp ⇒ Object
readonly
Gives a timestamp for when these results were generated.
Instance Method Summary collapse
-
#initialize ⇒ Transaction
constructor
Initialize does not take any parameters.
-
#to_h ⇒ Object
————————————————————————— to_h.
Constructor Details
#initialize ⇒ Transaction
Initialize does not take any parameters.
579 580 581 582 583 |
# File 'lib/xeme.rb', line 579 def initialize @timestamp = DateTime.now() @response = rand().to_s.sub(/\A0\./mu, '') @request = nil end |
Instance Attribute Details
#request ⇒ Object
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).
564 565 566 |
# File 'lib/xeme.rb', line 564 def request @request end |
#response ⇒ Object (readonly)
Gives a unique ID for these results.
567 568 569 |
# File 'lib/xeme.rb', line 567 def response @response end |
#timestamp ⇒ Object (readonly)
Gives a timestamp for when these results were generated.
570 571 572 |
# File 'lib/xeme.rb', line 570 def @timestamp end |
Instance Method Details
#to_h ⇒ Object
to_h
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
# File 'lib/xeme.rb', line 592 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 |