lab42_open_map 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +19 -0
- data/lib/lab42/open_map.rb +2 -1
- data/lib/lab42/open_map/implementation.rb +1 -1
- data/lib/lab42/open_map/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dba3bf6cc283aa87dc639a61a50c3ce3d53765c99b289f7d4ae51a420e0b6f39
|
4
|
+
data.tar.gz: 551bb79bcbdd352597d64ac3917518bb20047ee1b709e279f4aca875fff29695
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c73d638d3988aee6268467796c1a31f1ae20cf1e7d86ced45fddba4fa3a896e57405eaffcc4d57f2a75b2926822a74bc1a4bb917e877863804131573a8ea312
|
7
|
+
data.tar.gz: '039d68ac1928ebdd519aad8dc1e22d0e9d6b6f28002d86e8942b56897eea82fa1ffd0c8f4ee9f527f52d759e98461fe7825e0f558c4790f90810aa7102d001b6'
|
data/README.md
CHANGED
@@ -65,6 +65,24 @@ And we can use slice and get a nice counterpart `without`
|
|
65
65
|
expect( dog.without(:name, :breed) ).to eq({})
|
66
66
|
```
|
67
67
|
|
68
|
+
Example: `each_pair`
|
69
|
+
```ruby
|
70
|
+
expect( dog.each_pair.to_a ).to eq([[:name, "Rantanplan"],[ :breed, "You are kidding?"]])
|
71
|
+
|
72
|
+
```
|
73
|
+
|
74
|
+
`each_pair` is important for the following to work
|
75
|
+
Given we have `OpenStruct`
|
76
|
+
```ruby
|
77
|
+
require "ostruct"
|
78
|
+
```
|
79
|
+
Then we can create one from an `OpenMap`
|
80
|
+
```ruby
|
81
|
+
struct_dog = OpenStruct.new(dog)
|
82
|
+
expect( struct_dog.name ).to eq("Rantanplan")
|
83
|
+
|
84
|
+
```
|
85
|
+
|
68
86
|
And last, but certainly not least: _Named Access_
|
69
87
|
```ruby
|
70
88
|
expect(dog.name).to eq("Rantanplan")
|
@@ -72,6 +90,7 @@ And last, but certainly not least: _Named Access_
|
|
72
90
|
expect( dog.values ).to eq(["Rantanplan", "still unknown"])
|
73
91
|
```
|
74
92
|
|
93
|
+
|
75
94
|
## Context All About Named Access
|
76
95
|
|
77
96
|
Given the same dog again
|
data/lib/lab42/open_map.rb
CHANGED
@@ -3,7 +3,8 @@ require_relative "./open_map/implementation"
|
|
3
3
|
module Lab42
|
4
4
|
class OpenMap
|
5
5
|
extend Forwarder
|
6
|
-
|
6
|
+
include Enumerable
|
7
|
+
forward_all :[], :each, :each_pair, :empty?, :has_key?, :inject, :keys, :size, :slice, :values, to: :@hash
|
7
8
|
|
8
9
|
include Implementation
|
9
10
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lab42_open_map
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Dober
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lab42_result
|