remap 2.1.12 → 2.1.13
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/lib/remap/rule/map/optional.rb +18 -0
- data/lib/remap/rule/map/required.rb +19 -0
- data/lib/remap/rule/map.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: 526ddded05ad56900a9f6d1276069c48297adc6f5cb32ef08b955949bf9ee426
|
4
|
+
data.tar.gz: 239295549c9f0365453d19254fe21ff046755b6066f86a81596abaf102a98bbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c8d02457838ffe470359e5b9ff97cd2a31288928d238362eb38d85c190160b430242d2cfb401e9f7dbb418be4838dd6cbb1c282b68a7eababf5ad2d48030440
|
7
|
+
data.tar.gz: 191f1570f40e582c31e724e788882b54f83ff82e6d37931519451975355ceab5fb708260352523ddc10c849daa86d31c915221e9d539f2c069288462ca5dc45b
|
@@ -9,6 +9,24 @@ module Remap
|
|
9
9
|
# Represents an optional mapping rule
|
10
10
|
# When the mapping fails, the value is ignored
|
11
11
|
#
|
12
|
+
# @example Map [:name] to [:nickname]
|
13
|
+
# map = Map::Optional.call({
|
14
|
+
# path: {
|
15
|
+
# input: [:name],
|
16
|
+
# output: [:nickname]
|
17
|
+
# }
|
18
|
+
# })
|
19
|
+
#
|
20
|
+
# state = Remap::State.call({
|
21
|
+
# name: "John"
|
22
|
+
# })
|
23
|
+
#
|
24
|
+
# output = map.call(state) do |failure|
|
25
|
+
# raise failure.exeception
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# output.fetch(:value) # => { nickname: "John" }
|
29
|
+
#
|
12
30
|
# @param state [State]
|
13
31
|
#
|
14
32
|
# @return [State]
|
@@ -11,6 +11,25 @@ module Remap
|
|
11
11
|
# Represents a required mapping rule
|
12
12
|
# When it fails, the entire mapping is marked as failed
|
13
13
|
#
|
14
|
+
# @example Map [:name] to [:nickname]
|
15
|
+
# map = Map::Required.call({
|
16
|
+
# backtrace: caller,
|
17
|
+
# path: {
|
18
|
+
# input: [:name],
|
19
|
+
# output: [:nickname]
|
20
|
+
# }
|
21
|
+
# })
|
22
|
+
#
|
23
|
+
# state = Remap::State.call({
|
24
|
+
# name: "John"
|
25
|
+
# })
|
26
|
+
#
|
27
|
+
# output = map.call(state) do |failure|
|
28
|
+
# raise failure.exeception
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# output.fetch(:value) # => { nickname: "John" }
|
32
|
+
#
|
14
33
|
# @param state [State]
|
15
34
|
#
|
16
35
|
# @return [State]
|
data/lib/remap/rule/map.rb
CHANGED
@@ -28,7 +28,7 @@ module Remap
|
|
28
28
|
attribute? :path, Path.default { Path.call(EMPTY_HASH) }
|
29
29
|
|
30
30
|
# @return [Rule]
|
31
|
-
attribute :rule, Rule.default { Void.call(EMPTY_HASH) }
|
31
|
+
attribute? :rule, Rule.default { Void.call(EMPTY_HASH) }
|
32
32
|
|
33
33
|
# @return [Array<String>]
|
34
34
|
attribute? :backtrace, Types::Backtrace, default: EMPTY_ARRAY
|