hash_map 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/lib/hash_map/base.rb +6 -0
- data/lib/hash_map/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9fe3302f75b5cbae0c9e92deea5a40ec0aa4c240a94163077bed367534eda01
|
4
|
+
data.tar.gz: aa5d13b00571b3aa7d4010df835d19216dc08eeafb881ef5488683f950a582d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b1ad0e01f06bf40c444389490d0d639f5acae3385259ef1350a5efff5503a03bb2337d70ca2b3989c452a476873fca95bbe9a0013042dbd21ded764258d10b0
|
7
|
+
data.tar.gz: fe46e5d74f3388c75f2be15e49521b852108260e10bb4aac9909a7386a50e46f1a55c2826c2ab1e9ca87bc05d3e30ec653b4038ca450da1c9e46207083a6ae29
|
data/README.md
CHANGED
@@ -365,7 +365,7 @@ AfterEach.call(booleans)
|
|
365
365
|
#=> {"name"=>true, "age"=>false}
|
366
366
|
```
|
367
367
|
|
368
|
-
### `only_provided_keys`
|
368
|
+
### `only_provided_keys`, `only_provided_call`
|
369
369
|
|
370
370
|
```ruby
|
371
371
|
class RegularMapper < HashMap::Base
|
@@ -385,6 +385,12 @@ RegularMapper.call(input) # => {"name"=>"john", "lastname"=>nil, "phone"=>nil, "
|
|
385
385
|
OnlyProvidedKeysMapper.call(input) # => {"name"=>"john", phone: nil, "address"=>{"street"=>"Batu Mejan"}}
|
386
386
|
```
|
387
387
|
|
388
|
+
You can use a `only_provided_call` instead of call if you want to achieve the same result:
|
389
|
+
|
390
|
+
```ruby
|
391
|
+
RegularMapper.only_provided_call(input) # => {"name"=>"john", phone: nil, "address"=>{"street"=>"Batu Mejan"}}
|
392
|
+
```
|
393
|
+
|
388
394
|
### JSON Adapter
|
389
395
|
```ruby
|
390
396
|
class UserMapper < HashMap::Base
|
data/lib/hash_map/base.rb
CHANGED
@@ -14,6 +14,12 @@ module HashMap
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
def self.only_provided_call(*args)
|
18
|
+
Class.new(self) do
|
19
|
+
only_provided_keys
|
20
|
+
end.call(*args)
|
21
|
+
end
|
22
|
+
|
17
23
|
attr_reader :original, :options
|
18
24
|
def initialize(original, options = {})
|
19
25
|
@original = _transforms_input(prepare_input(original))
|
data/lib/hash_map/version.rb
CHANGED