File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -38,9 +38,7 @@ class Redacted < BSON::Document
38
38
#
39
39
# @since 2.1.0
40
40
def inspect
41
- '{' + reduce ( [ ] ) do |list , ( k , v ) |
42
- list << "#{ k . inspect } =>#{ redact ( k , v , __method__ ) } "
43
- end . join ( ', ' ) + '}'
41
+ redacted_string ( __method__ )
44
42
end
45
43
46
44
# Get a string representation of the options.
@@ -49,9 +47,7 @@ def inspect
49
47
#
50
48
# @since 2.1.0
51
49
def to_s
52
- '{' + reduce ( [ ] ) do |list , ( k , v ) |
53
- list << "#{ k . to_s } =>#{ redact ( k , v , __method__ ) } "
54
- end . join ( ', ' ) + '}'
50
+ redacted_string ( __method__ )
55
51
end
56
52
57
53
# Whether these options contain a given key.
@@ -70,6 +66,12 @@ def has_key?(key)
70
66
71
67
private
72
68
69
+ def redacted_string ( method )
70
+ '{' + reduce ( [ ] ) do |list , ( k , v ) |
71
+ list << "#{ k . send ( method ) } =>#{ redact ( k , v , method ) } "
72
+ end . join ( ', ' ) + '}'
73
+ end
74
+
73
75
def redact ( k , v , method )
74
76
return STRING_REPLACEMENT if SENSITIVE_OPTIONS . include? ( k . to_sym )
75
77
v . send ( method )
You can’t perform that action at this time.
0 commit comments