Class: Datadog::Core::Transport::HTTP::Adapters::Test
- Inherits:
-
Object
- Object
- Datadog::Core::Transport::HTTP::Adapters::Test
- Defined in:
- lib/datadog/core/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, **options) ⇒ Test
constructor
deprecated
Deprecated.
Positional parameters are deprecated. Use named parameters instead.
- #set_status!(status) ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(buffer = nil, **options) ⇒ Test
Deprecated.
Positional parameters are deprecated. Use named parameters instead.
Returns a new instance of Test.
18 19 20 21 22 |
# File 'lib/datadog/core/transport/http/adapters/test.rb', line 18 def initialize(buffer = nil, **) @buffer = buffer || [:buffer] @mutex = Mutex.new @status = 200 end |
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
12 13 14 |
# File 'lib/datadog/core/transport/http/adapters/test.rb', line 12 def buffer @buffer end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
12 13 14 |
# File 'lib/datadog/core/transport/http/adapters/test.rb', line 12 def status @status end |
Instance Method Details
#add_request(env) ⇒ Object
33 34 35 |
# File 'lib/datadog/core/transport/http/adapters/test.rb', line 33 def add_request(env) @mutex.synchronize { buffer << env } if buffer? end |
#buffer? ⇒ Boolean
29 30 31 |
# File 'lib/datadog/core/transport/http/adapters/test.rb', line 29 def buffer? !@buffer.nil? end |
#call(env) ⇒ Object
24 25 26 27 |
# File 'lib/datadog/core/transport/http/adapters/test.rb', line 24 def call(env) add_request(env) Response.new(status) end |
#set_status!(status) ⇒ Object
37 38 39 |
# File 'lib/datadog/core/transport/http/adapters/test.rb', line 37 def set_status!(status) @status = status end |
#url ⇒ Object
41 |
# File 'lib/datadog/core/transport/http/adapters/test.rb', line 41 def url; end |