collate 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56de0dde47539238e5ee06fd1559b31e41721b16
4
- data.tar.gz: d7b3f0a61cd26393b3ae3de6b7f8f2f8fe44943c
3
+ metadata.gz: bd2490c72305c02d1b4673b598db71192258ebf1
4
+ data.tar.gz: ac8e9482583d628e035304c749afc101cb4221ab
5
5
  SHA512:
6
- metadata.gz: 2cbd53ab5528c010fbdf73eabf8b8535feef9f019b553bad997a96b2fd3651d76f6b97810382571d7cecdf3d278990648dbe8f13fc160b9af27418c3262e8cd5
7
- data.tar.gz: 4e9544f77ec373d563704f0aaec2a28c80723360475a5317e7f41e26c9b30afd3e28820a5f8dd52b7d33b27be3671dcffbf20452a18f8f1cb0c2bff60c4d6740
6
+ metadata.gz: 7fca90116c85619627ae10df80d8e823cbd7fcba7f27fc972c39a184df17117961fefa372e5a46884fedcee3526f5e6b09995f2bd02b4af9f03b3d9e863c16c8
7
+ data.tar.gz: bfe21191da02ad18e9dfdcf1ed27c6eb30f5223215274aa9c948f5f4f1852cddb039844bc236fd5269072efda06944a56f8e79b1326b91ee14b8beacf431a3cf
@@ -95,6 +95,30 @@ module Collate
95
95
  end
96
96
 
97
97
  def apply_filter ar_rel, filter, param_value
98
+ ar_rel, ar_method, query_string, filter_value = if filter.field.is_a?(Array)
99
+ full_query_strings = []
100
+ full_filter_values = []
101
+
102
+ filter.field.each do |filter_field|
103
+ ar_rel, ar_method, query_string, filter_value = get_filter_data ar_rel, filter_field, filter, param_value
104
+
105
+ full_query_strings << query_string
106
+ full_filter_values << filter_value
107
+ end
108
+
109
+ [ar_rel, ar_method, full_query_strings.join(' OR '), full_filter_values.flatten]
110
+ else
111
+ get_filter_data ar_rel, filter.field.dup, filter, param_value
112
+ end
113
+
114
+ ar_rel = if query_string.include?('?')
115
+ ar_rel.send(ar_method, query_string, *filter_value)
116
+ else
117
+ ar_rel.send(ar_method, query_string)
118
+ end
119
+ end
120
+
121
+ def get_filter_data ar_rel, filter_field, filter, param_value
98
122
  filter_value = if param_value.duplicable?
99
123
  param_value.dup
100
124
  else
@@ -141,9 +165,7 @@ module Collate
141
165
 
142
166
  ar_rel = ar_rel.group(filter.grouping) if filter.grouping
143
167
 
144
- ar_rel = ar_rel.select(filter.field_select) if filter.field_select
145
-
146
- field_query = filter.field
168
+ field_query = filter_field
147
169
 
148
170
  filter.field_transformations.each do |ft|
149
171
  transformation = ft
@@ -230,15 +252,7 @@ module Collate
230
252
  query_string = filter_value.length.times.collect{query_string}.join(' OR ') if filter.or
231
253
  query_string = "NOT(#{query_string})" if filter.not
232
254
 
233
- ar_rel = if query_string.include?('?')
234
- if filter.or
235
- ar_rel.send(ar_method, query_string, *filter_value)
236
- else
237
- ar_rel.send(ar_method, query_string, filter_value)
238
- end
239
- else
240
- ar_rel.send(ar_method, query_string)
241
- end
255
+ [ar_rel, ar_method, query_string, filter_value]
242
256
  end
243
257
 
244
258
  end
@@ -8,7 +8,7 @@ module Collate
8
8
 
9
9
  attr_accessor :field, :operator, :base_model_table_name, :field_transformations, :label,
10
10
  :component, :joins, :value_transformations, :grouping, :html_id, :having,
11
- :joins_prefix, :not, :or, :field_select
11
+ :joins_prefix, :not, :or
12
12
 
13
13
  def initialize(field, opt={})
14
14
  opt.each do |f, value|
@@ -112,7 +112,7 @@ module Collate
112
112
  key += VALUE_TRANSFORMATIONS.index(transformation).to_s
113
113
  end
114
114
 
115
- "{#{key}}#{field}"
115
+ "{#{key}}#{field.to_s.gsub('[','').gsub(']','')}"
116
116
  end
117
117
  end
118
118
  end
@@ -1,3 +1,3 @@
1
1
  module Collate
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: collate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Page
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-02-18 00:00:00.000000000 Z
12
+ date: 2017-02-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler