Class: BlackHoleStruct
- Inherits:
-
Object
- Object
- BlackHoleStruct
- Defined in:
- lib/kube/cluster/manifest/middleware.rb
Overview
Patch BlackHoleStruct to handle arrays consistently.
The upstream gem does not recurse into arrays — hashes inside arrays are not converted to BlackHoleStruct on construction, and are not converted back to plain Hash on #to_h. This causes key-type inconsistencies after a Resource round-trip (symbol keys become string keys inside arrays).
These two patches fix both directions:
initialize — converts hashes inside arrays to BlackHoleStruct
to_h — converts BlackHoleStruct/arrays back to plain objects
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ BlackHoleStruct
constructor
A new instance of BlackHoleStruct.
- #to_h ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ BlackHoleStruct
Returns a new instance of BlackHoleStruct.
15 16 17 18 19 20 21 22 |
# File 'lib/kube/cluster/manifest/middleware.rb', line 15 def initialize(hash = {}) raise ArgumentError, "Argument should be a Hash" unless hash.is_a?(Hash) @table = {} hash.each do |key, value| @table[key.to_sym] = deep_wrap(value) end end |
Instance Method Details
#to_h ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/kube/cluster/manifest/middleware.rb', line 24 def to_h hash = {} @table.each do |key, value| hash[key] = deep_unwrap(value) end hash end |