kube_schema 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43157c3d38782006f39aa63c3cc0ae83eb4af0ad3f3974dde30d4ce27aa58a0d
4
- data.tar.gz: 510e764c90294d6c351c66930b95a056cbdbd7ac0a6f2d88bed0bb7ef374cc76
3
+ metadata.gz: d4d0fd333c3834e4593b60c9c57ada0fa0fd275175f55ffcfcc0616cd64fef1d
4
+ data.tar.gz: c427e577b4d92bc9241c21da35ae7f863f9ac0c1e354696a31e5292c8f818089
5
5
  SHA512:
6
- metadata.gz: d38e9e7e866071935b86fd788f8f52f0c751e5b2e71341f3509999cf0beefb193cfa04c92a03f2434865c6bb7771c8348f816b5bc25fd7506c7eb00759fccba3
7
- data.tar.gz: 6bdab5c5a67196f998e0c8e527964c9921f8cdfc931742fe9a924cf82b4e31c5a54236c22a4bd5c8fe261310affc2cba813a56f248ab38ed6903e5e5bd300056
6
+ metadata.gz: 752d0e5bae651ce4734e46ac9a886f06253dacd5193861729509c92e39bdfca81a543ad3267440b1499725147466783e1aca904312a1184e9c6ce77d311d1282
7
+ data.tar.gz: 893b866464d3f4f8565d7e73c840c1f2cfaf4421dcfeeb867374a606d1b7b34b89118a4ccecbba47f58c767f33c4d2969deaa427b4ad3e38117f987c8af76db7
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kube
4
4
  module Schema
5
- VERSION = "1.2.2"
5
+ VERSION = "1.2.3"
6
6
  end
7
7
  end
data/lib/kube/schema.rb CHANGED
@@ -75,3 +75,51 @@ module Kube
75
75
  end
76
76
  end
77
77
  end
78
+
79
+ # Patch BlackHoleStruct to handle arrays consistently.
80
+ #
81
+ # The upstream gem does not recurse into arrays — hashes inside arrays
82
+ # are not converted to BlackHoleStruct on construction, and are not
83
+ # converted back to plain Hash on #to_h. This causes key-type
84
+ # inconsistencies after a Resource round-trip (symbol keys become
85
+ # string keys inside arrays).
86
+ #
87
+ # These two patches fix both directions:
88
+ # initialize — converts hashes inside arrays to BlackHoleStruct
89
+ # to_h — converts BlackHoleStruct/arrays back to plain objects
90
+ class BlackHoleStruct
91
+ def initialize(hash = {})
92
+ raise ArgumentError, "Argument should be a Hash" unless hash.is_a?(Hash)
93
+
94
+ @table = {}
95
+ hash.each do |key, value|
96
+ @table[key.to_sym] = deep_wrap(value)
97
+ end
98
+ end
99
+
100
+ def to_h
101
+ hash = {}
102
+ @table.each do |key, value|
103
+ hash[key] = deep_unwrap(value)
104
+ end
105
+ hash
106
+ end
107
+
108
+ private
109
+
110
+ def deep_wrap(value)
111
+ case value
112
+ when Hash then self.class.new(value)
113
+ when Array then value.map { |v| deep_wrap(v) }
114
+ else value
115
+ end
116
+ end
117
+
118
+ def deep_unwrap(value)
119
+ case value
120
+ when self.class then value.to_h
121
+ when Array then value.map { |v| deep_unwrap(v) }
122
+ else value
123
+ end
124
+ end
125
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kube_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan K