dry-logic 1.0.7 → 1.0.8
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/CHANGELOG.md +10 -0
- data/lib/dry/logic/rule/interface.rb +29 -34
- data/lib/dry/logic/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: 18fd19e7ba009817c12de16b828fb0e1dd04f1e5d2305fa9eeb8be9a55681473
|
4
|
+
data.tar.gz: a4f2ff3297ab4684323489bd0a371f759b1b99d0a5c5f5425a3158f4d8af45e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c57af697d43afe951a6cfdce3a9afd2ce12399b95e6d48f9468c84a2de33299d8a20b8f1851652a86cb922868974b2be80f434d38c8086022db42d9baa7df5dc
|
7
|
+
data.tar.gz: a33e8cfcec95668d7189ac1921bce8c88602dd25fea59f10174cef42ff7130cd9bb4285884d4c241eeb98fcd842a5268078c14649851e1b24fc20a56633fcd43
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,8 @@ module Dry
|
|
4
4
|
module Logic
|
5
5
|
class Rule
|
6
6
|
class Interface < ::Module
|
7
|
+
SPLAT = ["*rest"].freeze
|
8
|
+
|
7
9
|
attr_reader :arity
|
8
10
|
|
9
11
|
attr_reader :curried
|
@@ -18,12 +20,10 @@ module Dry
|
|
18
20
|
|
19
21
|
define_constructor if curried?
|
20
22
|
|
21
|
-
if
|
22
|
-
define_splat_application
|
23
|
-
elsif constant?
|
23
|
+
if constant?
|
24
24
|
define_constant_application
|
25
25
|
else
|
26
|
-
|
26
|
+
define_application
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -32,7 +32,7 @@ module Dry
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def variable_arity?
|
35
|
-
arity.
|
35
|
+
arity.negative?
|
36
36
|
end
|
37
37
|
|
38
38
|
def curried?
|
@@ -41,7 +41,13 @@ module Dry
|
|
41
41
|
|
42
42
|
def unapplied
|
43
43
|
if variable_arity?
|
44
|
-
-1
|
44
|
+
unapplied = arity.abs - 1 - curried
|
45
|
+
|
46
|
+
if unapplied.negative?
|
47
|
+
0
|
48
|
+
else
|
49
|
+
unapplied
|
50
|
+
end
|
45
51
|
else
|
46
52
|
arity - curried
|
47
53
|
end
|
@@ -51,8 +57,19 @@ module Dry
|
|
51
57
|
if constant?
|
52
58
|
"Constant"
|
53
59
|
else
|
54
|
-
arity_str =
|
55
|
-
|
60
|
+
arity_str =
|
61
|
+
if variable_arity?
|
62
|
+
"Variable#{arity.abs - 1}Arity"
|
63
|
+
else
|
64
|
+
"#{arity}Arity"
|
65
|
+
end
|
66
|
+
|
67
|
+
curried_str =
|
68
|
+
if curried?
|
69
|
+
"#{curried}Curried"
|
70
|
+
else
|
71
|
+
EMPTY_STRING
|
72
|
+
end
|
56
73
|
|
57
74
|
"#{arity_str}#{curried_str}"
|
58
75
|
end
|
@@ -91,32 +108,10 @@ module Dry
|
|
91
108
|
end
|
92
109
|
end
|
93
110
|
|
94
|
-
def
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
else
|
99
|
-
"@predicate[*input]"
|
100
|
-
end
|
101
|
-
|
102
|
-
module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
|
103
|
-
def call(*input)
|
104
|
-
if #{application}
|
105
|
-
Result::SUCCESS
|
106
|
-
else
|
107
|
-
Result.new(false, id) { ast(*input) }
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def [](*input)
|
112
|
-
#{application}
|
113
|
-
end
|
114
|
-
RUBY
|
115
|
-
end
|
116
|
-
|
117
|
-
def define_fixed_application
|
118
|
-
parameters = unapplied_args.join(", ")
|
119
|
-
application = "@predicate[#{(curried_args + unapplied_args).join(", ")}]"
|
111
|
+
def define_application
|
112
|
+
splat = variable_arity? ? SPLAT : EMPTY_ARRAY
|
113
|
+
parameters = (unapplied_args + splat).join(", ")
|
114
|
+
application = "@predicate[#{(curried_args + unapplied_args + splat).join(", ")}]"
|
120
115
|
|
121
116
|
module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
|
122
117
|
def call(#{parameters})
|
data/lib/dry/logic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-logic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|