jquery_query_builder-rails 0.2.0 → 0.2.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/README.md +13 -2
- data/lib/jquery_query_builder/rails/version.rb +1 -1
- data/lib/jquery_query_builder/rule.rb +3 -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: 72be92d1c4dcc18dce5beb1117a7bfc9e4467697
|
4
|
+
data.tar.gz: 30b35c5cc38dab3ab4bfd7bfc1e674aea5872e23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f84a280a29d67c387d89f9d313b3ee5c38e0daeb508b4e4c4a4c7ba6b78f9d3c71ff0bd4d6d4c66c4c5b1d151c6547f331ec931e99099e339af64791eef012e
|
7
|
+
data.tar.gz: dc4388ae9b96e492c74c0b7f1521f40da7377cca0a51de7a081a98e00d64fe9ee90e96ea95396f639bc13c7acf596c1126e70f43ba709218f016870b08701f61
|
data/README.md
CHANGED
@@ -63,10 +63,13 @@ You can use the evaluator to check if objects match the json rules produced by t
|
|
63
63
|
|
64
64
|
Objects are hashes or other objects that can be accessed with hash-like bracket functionality e.g. object['test'].
|
65
65
|
|
66
|
+
You can access nested fields with a dot notation.
|
67
|
+
e.g. fields.Question to access {'fields' => {'Question' => 'Answer'}}
|
68
|
+
|
66
69
|
## Example Usage
|
67
70
|
```ruby
|
68
71
|
rule_json = %|{
|
69
|
-
"condition": "
|
72
|
+
"condition": "OR",
|
70
73
|
"rules": [{
|
71
74
|
"id": "Integer_Question",
|
72
75
|
"field": "Integer_Question",
|
@@ -74,10 +77,18 @@ rule_json = %|{
|
|
74
77
|
"input": "text",
|
75
78
|
"operator": "equal",
|
76
79
|
"value": "5"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"id": "fields.String_Question",
|
83
|
+
"field": "fields.String_Question",
|
84
|
+
"type": "string",
|
85
|
+
"input": "text",
|
86
|
+
"operator": "equal",
|
87
|
+
"value": "test"
|
77
88
|
}]
|
78
89
|
}|
|
79
90
|
|
80
|
-
object_1 = {'Integer_Question' => 5}
|
91
|
+
object_1 = {'Integer_Question' => 5, 'fields' => {'String_Question' => 'test'}}
|
81
92
|
object_2 = {'Integer_Question' => 15}
|
82
93
|
objects = [object_1, object_2]
|
83
94
|
|
@@ -22,7 +22,7 @@ module JqueryQueryBuilder
|
|
22
22
|
fields = field.split('.')
|
23
23
|
result = object
|
24
24
|
fields.each do |field|
|
25
|
-
result =
|
25
|
+
result = result[field]
|
26
26
|
break if result.nil?
|
27
27
|
end
|
28
28
|
if result.is_a? Array
|
@@ -41,6 +41,8 @@ module JqueryQueryBuilder
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def typecast_value(value_to_cast)
|
44
|
+
return nil if value_to_cast.nil?
|
45
|
+
|
44
46
|
case type
|
45
47
|
when 'string'
|
46
48
|
value_to_cast.to_s
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery_query_builder-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Hirst
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|