lab42_open_map 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48f632ae67cd9d116fb9bc918c1f24f6eacccf50629b2cfb74251887aab3797c
4
- data.tar.gz: fef6938854f3895786503f0b13e78c84be136f31cfcd7cf06650a621c87e1e88
3
+ metadata.gz: dba3bf6cc283aa87dc639a61a50c3ce3d53765c99b289f7d4ae51a420e0b6f39
4
+ data.tar.gz: 551bb79bcbdd352597d64ac3917518bb20047ee1b709e279f4aca875fff29695
5
5
  SHA512:
6
- metadata.gz: b9407f0c3a9aadecee79621cd64e214c1b73a75d1f912ab822ea688eb6135869f1b2e135c3cef408c8d61ad26b044c82a2ee3aaaa434b989bbffa8dd68c32a31
7
- data.tar.gz: d7e8b2fc4fc217640995e4af1b10d5de504d1b17bb13a87abafa3aa51e962162d6719876518b6adb31b5259a0369c2b128e2a3280af3bc7ba8afc9eab9ae7de5
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
@@ -3,7 +3,8 @@ require_relative "./open_map/implementation"
3
3
  module Lab42
4
4
  class OpenMap
5
5
  extend Forwarder
6
- forward_all :[], :empty?, :has_key?, :inject, :keys, :map, :reduce, :size, :slice, :values, to: :@hash
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
 
@@ -13,7 +13,7 @@ module Lab42
13
13
  end
14
14
 
15
15
  def sans(*keys)
16
- self.class.new(without(*keys))
16
+ self.class.new(**without(*keys))
17
17
  end
18
18
 
19
19
  def update(**kwds)
@@ -1,7 +1,7 @@
1
1
  module Lab42
2
2
  class OpenMap
3
3
  class << self
4
- def version; "0.1.0" end
4
+ def version; "0.1.1" end
5
5
  end
6
6
  end
7
7
  end
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.0
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-20 00:00:00.000000000 Z
11
+ date: 2020-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lab42_result