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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21eabfc82ba1b10f2f86fc1b5a373fce3b787a25
4
- data.tar.gz: 242467b72d023ec7574792f90711cc59b695f7fe
3
+ metadata.gz: 72be92d1c4dcc18dce5beb1117a7bfc9e4467697
4
+ data.tar.gz: 30b35c5cc38dab3ab4bfd7bfc1e674aea5872e23
5
5
  SHA512:
6
- metadata.gz: bf8fc6b0d04145a56c2c15fc0decec875f4c8b179fe1a37581b81a6d89cb56cf5326d384f19e8020acf321c2613948c3e122251ce7653eb5d182461c4207df02
7
- data.tar.gz: 9647417717b125078c313f76bf58db43cd200c62ae78f5a78688335b26984b5ca1166f86ac39d20b0f60041219ee4ed10a837d30194db2cd889e18a09d62c67d
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": "AND",
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
 
@@ -1,5 +1,5 @@
1
1
  module JqueryQueryBuilder
2
2
  module Rails
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -22,7 +22,7 @@ module JqueryQueryBuilder
22
22
  fields = field.split('.')
23
23
  result = object
24
24
  fields.each do |field|
25
- result = object[field]
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.0
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-26 00:00:00.000000000 Z
11
+ date: 2016-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties