Skip to content

Commit 227b8db

Browse files
committed
✨ Serialization Extensions (i)
1 parent 0bf5536 commit 227b8db

23 files changed

+106
-51
lines changed

.rubocop_gradual.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"spec/snaky_hash/bad_snake_spec.rb:3931746112": [
1212
[3, 16, 11, "RSpec/DescribeClass: The first argument to describe should be the class or module being tested.", 1577626599]
1313
],
14-
"spec/snaky_hash/snake_spec.rb:3264128361": [
14+
"spec/snaky_hash/snake_spec.rb:3662358368": [
1515
[4, 3, 92, "RSpec/LeakyConstantDeclaration: Stub class constant instead of declaring explicitly.", 3047242215]
1616
]
1717
}

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,12 @@ This is also not a bug, though if you need different behavior, there is a soluti
193193

194194
You can write your own arbitrary extensions:
195195

196-
* hash load extensions operate on the hash, and nested hashes
197-
* use `::load_hash_extensions.add(:extension_name) {}`
198-
* load extensions operate on the values, and nested hash values, if any
199-
* use `::load_extensions.add(:extension_name) {}`
200-
* dump extensions operate on the values, and nested hash values, if any
201-
* use `::dump_extensions.add(:extension_name) {}`
196+
* "Hash Load" extensions operate on the hash, and nested hashes
197+
* use `::load_hash_extensions.add(:extension_name) { |hash| }`
198+
* "Load" extensions operate on the values, and nested hash's values, if any
199+
* use `::load_extensions.add(:extension_name) { |value| }`
200+
* "Dump" extensions operate on the values, and nested hash's values, if any
201+
* use `::dump_extensions.add(:extension_name) { |value| }`
202202

203203
#### Example
204204

@@ -234,16 +234,16 @@ hydrated = MyExtSnakedHash.load(dump) # => {1 => "a", "0": 4, very_fine_hat: {3
234234
hydrated.class # => MyExtSnakedHash
235235
hydrated["1"] # => nil
236236
hydrated[1] # => "a"
237-
hydrated["2"] # => nil
238-
hydrated[2] # => 4
239237
hydrated["0"] # => 4
240238
hydrated[0] # => nil
241239
hydrated.very_fine_hat # => {3 => "v", 5 => 7, very_fine_hat: "feathers"}
242240
hydrated.very_fine_hat.very_fine_hat # => "feathers"
243-
hydrated.very_fine_hat[:very_fine_hat] # => 'Feathers'
244-
hydrated.very_fine_hat["very_fine_hat"] # => 'Feathers'
241+
hydrated.very_fine_hat[:very_fine_hat] # => 'feathers'
242+
hydrated.very_fine_hat["very_fine_hat"] # => 'feathers'
245243
```
246244

245+
See the specs for more examples.
246+
247247
### Stranger Things
248248

249249
I don't recommend using these features... but they exist (for now).

doc/SnakyHash.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ <h2>Overview</h2><div class="docstring">
123123
</div>
124124

125125
<div id="footer">
126-
Generated on Thu May 22 01:26:13 2025 by
126+
Generated on Thu May 22 01:51:49 2025 by
127127
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
128128
0.9.37 (ruby-3.4.3).
129129
</div>

doc/SnakyHash/Error.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
</div>
115115

116116
<div id="footer">
117-
Generated on Thu May 22 01:26:13 2025 by
117+
Generated on Thu May 22 01:51:49 2025 by
118118
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119119
0.9.37 (ruby-3.4.3).
120120
</div>

doc/SnakyHash/Extensions.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ <h3 class="signature " id="run-instance_method">
446446
</div>
447447

448448
<div id="footer">
449-
Generated on Thu May 22 01:26:13 2025 by
449+
Generated on Thu May 22 01:51:49 2025 by
450450
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
451451
0.9.37 (ruby-3.4.3).
452452
</div>

doc/SnakyHash/Serializer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ <h3 class="signature " id="load-instance_method">
316316
</div>
317317

318318
<div id="footer">
319-
Generated on Thu May 22 01:26:13 2025 by
319+
Generated on Thu May 22 01:51:49 2025 by
320320
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
321321
0.9.37 (ruby-3.4.3).
322322
</div>

doc/SnakyHash/Serializer/BackportedInstanceMethods.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ <h3 class="signature first" id="transform_values-instance_method">
190190
</div>
191191

192192
<div id="footer">
193-
Generated on Thu May 22 01:26:13 2025 by
193+
Generated on Thu May 22 01:51:49 2025 by
194194
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
195195
0.9.37 (ruby-3.4.3).
196196
</div>

doc/SnakyHash/Serializer/Modulizer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ <h3 class="signature first" id="to_extended_mod-class_method">
189189
</div>
190190

191191
<div id="footer">
192-
Generated on Thu May 22 01:26:13 2025 by
192+
Generated on Thu May 22 01:51:49 2025 by
193193
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
194194
0.9.37 (ruby-3.4.3).
195195
</div>

doc/SnakyHash/Snake.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ <h3 class="signature first" id="included-instance_method">
275275
</div>
276276

277277
<div id="footer">
278-
Generated on Thu May 22 01:26:13 2025 by
278+
Generated on Thu May 22 01:51:49 2025 by
279279
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
280280
0.9.37 (ruby-3.4.3).
281281
</div>

doc/SnakyHash/Snake/SnakyModulizer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ <h3 class="signature first" id="to_mod-class_method">
261261
</div>
262262

263263
<div id="footer">
264-
Generated on Thu May 22 01:26:13 2025 by
264+
Generated on Thu May 22 01:51:49 2025 by
265265
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
266266
0.9.37 (ruby-3.4.3).
267267
</div>

0 commit comments

Comments
 (0)