Class: Morpheus::Client::RequestFormatter
- Inherits:
-
Object
- Object
- Morpheus::Client::RequestFormatter
show all
- Defined in:
- lib/morpheus/client/request_formatter.rb
Constant Summary
collapse
- MAGENTA =
ActiveSupport::LogSubscriber::MAGENTA
- CYAN =
ActiveSupport::LogSubscriber::CYAN
- GREEN =
ActiveSupport::LogSubscriber::GREEN
- RED =
ActiveSupport::LogSubscriber::RED
- YELLOW =
ActiveSupport::LogSubscriber::YELLOW
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(subscriber, event, odd) ⇒ RequestFormatter
Returns a new instance of RequestFormatter.
16
17
18
19
20
|
# File 'lib/morpheus/client/request_formatter.rb', line 16
def initialize(subscriber, event, odd)
@subscriber = subscriber
@event = event
@odd = odd
end
|
Instance Attribute Details
#event ⇒ Object
Returns the value of attribute event.
10
11
12
|
# File 'lib/morpheus/client/request_formatter.rb', line 10
def event
@event
end
|
#subscriber ⇒ Object
Returns the value of attribute subscriber.
10
11
12
|
# File 'lib/morpheus/client/request_formatter.rb', line 10
def subscriber
@subscriber
end
|
Class Method Details
.call(subscriber, event, odd) ⇒ Object
12
13
14
|
# File 'lib/morpheus/client/request_formatter.rb', line 12
def self.call(subscriber, event, odd)
new(subscriber, event, odd).call
end
|
Instance Method Details
#color(*args) ⇒ Object
34
35
36
|
# File 'lib/morpheus/client/request_formatter.rb', line 34
def color(*args)
subscriber.send(:color, *args)
end
|
38
39
40
41
42
|
# File 'lib/morpheus/client/request_formatter.rb', line 38
def formatted_payload
payload = "#{event.payload[:url]}"
payload << " #{event.payload[:params].inspect}" unless event.payload[:params].blank?
payload
end
|
#odd? ⇒ Boolean
22
23
24
|
# File 'lib/morpheus/client/request_formatter.rb', line 22
def odd?
@odd
end
|
#payload ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/morpheus/client/request_formatter.rb', line 26
def payload
if odd?
color(formatted_payload, nil, true)
else
formatted_payload
end
end
|
#request_color ⇒ Object
44
45
46
|
# File 'lib/morpheus/client/request_formatter.rb', line 44
def request_color
odd? ? MAGENTA : CYAN
end
|