Class: Morpheus::Client::UncachedRequestFormatter
Constant Summary
RequestFormatter::CYAN, RequestFormatter::GREEN, RequestFormatter::MAGENTA, RequestFormatter::RED, RequestFormatter::YELLOW
Instance Attribute Summary
#event, #subscriber
Instance Method Summary
collapse
call, #color, #formatted_payload, #initialize, #odd?, #payload, #request_color
Instance Method Details
#call ⇒ Object
5
6
7
|
# File 'lib/morpheus/client/uncached_request_formatter.rb', line 5
def call
"#{request_statement} #{response_statement} #{payload}"
end
|
#duration ⇒ Object
25
26
27
28
|
# File 'lib/morpheus/client/uncached_request_formatter.rb', line 25
def duration
value = response.time * 1000
"#{value}ms"
end
|
#request_statement ⇒ Object
9
10
11
12
13
14
|
# File 'lib/morpheus/client/uncached_request_formatter.rb', line 9
def request_statement
klass = event.payload[:class]
method = event.payload[:method].to_s.upcase
statement = "#{klass} #{method} (#{duration})"
color(statement, request_color, true)
end
|
#response ⇒ Object
21
22
23
|
# File 'lib/morpheus/client/uncached_request_formatter.rb', line 21
def response
event.payload[:response]
end
|
#response_color ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/morpheus/client/uncached_request_formatter.rb', line 30
def response_color
case response.code
when 200..299 then GREEN
when 400..599 then RED
else YELLOW
end
end
|
#response_statement ⇒ Object
16
17
18
19
|
# File 'lib/morpheus/client/uncached_request_formatter.rb', line 16
def response_statement
statement = "[#{response.code}]"
color(statement, response_color, true)
end
|