json_logic 0.4.0 → 0.4.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/lib/json_logic.rb +5 -0
- data/lib/json_logic/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 677b105ac790d969a647b1244272dec1d489ce8f
|
4
|
+
data.tar.gz: 2c2541c2edc2616d65e408084cb069350551dfa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 061f7d199adc1ddd4482aa446e10ea3cfadaeca343e4f4ec1de6629eab3db944828065ef4d123ac5153dcf16d8860a5767ec4f30767c411c4a0055233f5d4a45
|
7
|
+
data.tar.gz: 8451f7ac97031790f913c6b223d243ec476ddf71e1205f19b1f604c6a182960aa860bbffee0117aa98e1d245e6ffd38ad0bf74ed5d69ff139d4c8f213ec7a3b0
|
data/lib/json_logic.rb
CHANGED
@@ -4,7 +4,12 @@ require 'json_logic/truthy'
|
|
4
4
|
require 'json_logic/operation'
|
5
5
|
module JSONLogic
|
6
6
|
def self.apply(logic, data)
|
7
|
+
if logic.is_a?(Array)
|
8
|
+
return logic.map { |val| apply(val, data) }
|
9
|
+
end
|
10
|
+
|
7
11
|
return logic unless logic.is_a?(Hash) # pass-thru
|
12
|
+
|
8
13
|
data = data.stringify_keys if data.is_a?(Hash) # Stringify keys to keep out problems with symbol/string mismatch
|
9
14
|
operator, values = logic.first # unwrap single-key hash
|
10
15
|
values = [values] unless values.is_a?(Array) # syntactic sugar
|
data/lib/json_logic/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_logic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenneth Geerts
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-10-
|
12
|
+
date: 2018-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|