Skip to content

Commit 75a58af

Browse files
committed
RUBY-1021 to_s method
1 parent a10066a commit 75a58af

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/mongo/options/sensitive_options.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,21 @@ class SensitiveOptions < BSON::Document
2222

2323
def inspect
2424
'{' + reduce('') do |string, (k, v)|
25-
string << "#{k}=>#{redact(k,v)}"
25+
string << "#{k.inspect}=>#{redact(k, v, __method__)}"
26+
end + '}'
27+
end
28+
29+
def to_s
30+
'{' + reduce('') do |string, (k, v)|
31+
string << "#{k.to_s}=>#{redact(k, v, __method__)}"
2632
end + '}'
2733
end
2834

2935
private
3036

31-
def redact(k, v)
37+
def redact(k, v, method)
3238
return REDACTED_STRING if SENSITIVE_OPTIONS.include?(k.to_sym)
33-
v.inspect
39+
v.send(method)
3440
end
3541
end
3642
end

0 commit comments

Comments
 (0)