Class: Datadog::Transport::HTTP::Adapters::Test
- Inherits:
-
Object
- Object
- Datadog::Transport::HTTP::Adapters::Test
- Defined in:
- lib/ddtrace/transport/http/adapters/test.rb
Overview
Adapter for testing
Defined Under Namespace
Classes: Response
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #add_request(env) ⇒ Object
- #buffer? ⇒ Boolean
- #call(env) ⇒ Object
-
#initialize(buffer = nil) ⇒ Test
constructor
A new instance of Test.
- #set_status!(status) ⇒ Object
Constructor Details
#initialize(buffer = nil) ⇒ Test
Returns a new instance of Test.
13 14 15 16 17 |
# File 'lib/ddtrace/transport/http/adapters/test.rb', line 13 def initialize(buffer = nil) @buffer = buffer @mutex = Mutex.new @status = 200 end |
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
9 10 11 |
# File 'lib/ddtrace/transport/http/adapters/test.rb', line 9 def buffer @buffer end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/ddtrace/transport/http/adapters/test.rb', line 9 def status @status end |
Instance Method Details
#add_request(env) ⇒ Object
28 29 30 |
# File 'lib/ddtrace/transport/http/adapters/test.rb', line 28 def add_request(env) @mutex.synchronize { buffer << env } if buffer? end |
#buffer? ⇒ Boolean
24 25 26 |
# File 'lib/ddtrace/transport/http/adapters/test.rb', line 24 def buffer? !@buffer.nil? end |
#call(env) ⇒ Object
19 20 21 22 |
# File 'lib/ddtrace/transport/http/adapters/test.rb', line 19 def call(env) add_request(env) Response.new(status) end |
#set_status!(status) ⇒ Object
32 33 34 |
# File 'lib/ddtrace/transport/http/adapters/test.rb', line 32 def set_status!(status) @status = status end |