yep_searchable 0.0.4 → 0.0.5

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.
@@ -182,6 +182,7 @@ module YepSearchable
182
182
  end
183
183
 
184
184
  query_string = ""
185
+ entity_counter = 0
185
186
 
186
187
  reflec_keys = self.reflections.keys
187
188
 
@@ -193,6 +194,8 @@ module YepSearchable
193
194
 
194
195
  if ids.nil? or ids.empty?
195
196
  next
197
+ else
198
+ entity_counter += 1
196
199
  end
197
200
 
198
201
  if query_string.empty?
@@ -209,6 +212,12 @@ module YepSearchable
209
212
  query_string = "#{query_string})"
210
213
  end
211
214
  end
215
+
216
+ if entity_counter > 1
217
+ (entity_counter-1).times do
218
+ query_string = "#{query_string})"
219
+ end
220
+ end
212
221
 
213
222
  return query_string
214
223
 
@@ -225,7 +234,8 @@ module YepSearchable
225
234
  end
226
235
 
227
236
  query_string = ""
228
-
237
+ entity_counter = 0
238
+
229
239
  yep_res.each do |resource|
230
240
  if !resource[:class_name].to_s.camelize.constantize.superclass.to_s.eql?"YepSearchable::YepResource"
231
241
  raise SearchableError, "Only classes that implement YepResource are allowed"
@@ -235,6 +245,8 @@ module YepSearchable
235
245
 
236
246
  if ids.nil? or ids.empty?
237
247
  next
248
+ else
249
+ entity_counter += 1
238
250
  end
239
251
 
240
252
  if query_string.empty?
@@ -248,10 +260,16 @@ module YepSearchable
248
260
  end
249
261
 
250
262
  query_string = query_string[0, query_string.size - 1]
251
- query_string = "#{query_string})"
263
+ query_string = "#{query_string})"
252
264
 
253
265
  end
254
266
 
267
+ if entity_counter > 1
268
+ (entity_counter -1).times do
269
+ query_string = "#{query_string})"
270
+ end
271
+ end
272
+
255
273
  return query_string
256
274
  end
257
275
  end
@@ -1,3 +1,3 @@
1
1
  module YepSearchable
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yep_searchable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-01 00:00:00.000000000 Z
12
+ date: 2013-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -68,7 +68,7 @@ rubyforge_project:
68
68
  rubygems_version: 1.8.24
69
69
  signing_key:
70
70
  specification_version: 3
71
- summary: YepSearchable-0.0.4
71
+ summary: YepSearchable-0.0.5
72
72
  test_files:
73
73
  - test/performance/browsing_test.rb
74
74
  - test/test_helper.rb