Commit b19133c
committed
(PUP-11061) Override Sensitive equality/hash
Previously, instances of Sensitive with the same @value were not equal.
This patch overrides ==, eql? and hash to fix that.
a = Puppet::Pops::Types::PSensitiveType::Sensitive.new('secret')
b = Puppet::Pops::Types::PSensitiveType::Sensitive.new('secret')
a == b
# true
h = { a => 1 }
h[b] = 2
h
# {#<Sensitive [value redacted]>=>2}1 parent 2098009 commit b19133c
File tree
2 files changed
+28
-0
lines changed- lib/puppet/pops/types
- spec/unit/pops/types
2 files changed
+28
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
27 | 37 | | |
28 | 38 | | |
29 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
116 | 134 | | |
117 | 135 | | |
118 | 136 | | |
| |||
0 commit comments