Class: Rollbar::Truncation::StringsStrategy
- Inherits:
-
Object
- Object
- Rollbar::Truncation::StringsStrategy
show all
- Includes:
- Mixin
- Defined in:
- lib/rollbar/truncation/strings_strategy.rb
Constant Summary
collapse
- STRING_THRESHOLDS =
[1024, 512, 256, 128].freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Mixin
#dump, #select_frames, #truncate?
Class Method Details
.call(payload) ⇒ Object
11
12
13
|
# File 'lib/rollbar/truncation/strings_strategy.rb', line 11
def self.call(payload)
new.call(payload)
end
|
Instance Method Details
#call(payload) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/rollbar/truncation/strings_strategy.rb', line 15
def call(payload)
result = nil
STRING_THRESHOLDS.each do |threshold|
truncate_proc = truncate_strings_proc(threshold)
::Rollbar::Util.iterate_and_update(payload, truncate_proc)
result = dump(payload)
break unless truncate?(result)
end
result
end
|
#truncate_strings_proc(threshold) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/rollbar/truncation/strings_strategy.rb', line 30
def truncate_strings_proc(threshold)
proc do |value|
if value.is_a?(String) && value.length > threshold
Rollbar::Util.truncate(value, threshold)
else
value
end
end
end
|