search_me 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/lib/search_me/search.rb +25 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
OGNjZGY4MzI0ZDNmYjJlNjljZWYzMjdmMTRhMzBmNjI2YWNiYzJjZA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4dc0217a072a11faf8495a56272dff5b46303e1e
|
4
|
+
data.tar.gz: 57733d8dfd4cf36396172cc30292fbc31e30f930
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NjgwZGQzZDM5MTljMDc1ZjVhNDlkMmFjZjk5YmM1YzUzNzYwMjI0OGUxODM3
|
11
|
-
ZTE0NzA3MTZlNzg3NzRmNGU2OWRiNjg5YWI3OTM0MzExYzhjOGM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
Mzc1YTU0OTdiN2IwOWI0YzMzMDE1YzRlMWM4ZTc1MmZjYTMwZGE0MDA1Yjc1
|
14
|
-
ODc0OWMwMWUzODIzNjAxOGYyN2ZiODFjNzEwYjNjNGQyY2VjZjQyOWJlZjU0
|
15
|
-
N2U1MWU0MjQzMWZiN2NjYzY1OWFhNWJjZjZiZjA0NDY2ODdiYTg=
|
6
|
+
metadata.gz: a5a9ffa37a4f9d9fab544a86adc9f732a74be138aa2bc7558f9d25aa32d5b082f3ce2f0a532426188934a3ddd21a5201ea853ad291df0007361312976dee7c26
|
7
|
+
data.tar.gz: 71d3ba7dd7f2994344ee6f892b32d39d5e5c5fc8ac4f045e6b3c3a09725242fdfbd9fac24ef6d98cb4e5b225134c8453f2f53bf21223ee95bf3ea331ebffe48b
|
data/lib/search_me/search.rb
CHANGED
@@ -117,7 +117,16 @@ module SearchMe
|
|
117
117
|
"id IN (#{object_ids(objs, f_key).join(',')})"
|
118
118
|
}
|
119
119
|
when :has_many_through
|
120
|
-
warn 'WARNING: has_many_through
|
120
|
+
warn 'WARNING: has_many_through in development'
|
121
|
+
self.advanced_search_reflection_group(type,search_terms) {
|
122
|
+
|reflection,objs|
|
123
|
+
|
124
|
+
f_key = "#{name_for(reflection.name)}_id"
|
125
|
+
related = through_klass_for_reflection(reflection)
|
126
|
+
.where(f_key => objs.ids)
|
127
|
+
|
128
|
+
"id IN (#{object_ids(related).join(',')})"
|
129
|
+
}
|
121
130
|
end
|
122
131
|
}
|
123
132
|
self.where(join(conditions))
|
@@ -147,7 +156,14 @@ module SearchMe
|
|
147
156
|
"id IN (#{object_ids(objs, f_key).join(',')})"
|
148
157
|
}
|
149
158
|
when :has_many_through
|
150
|
-
warn 'WARNING: has_many_through
|
159
|
+
warn 'WARNING: has_many_through in development'
|
160
|
+
self.search_reflection_group(type, term) { |reflection,objs|
|
161
|
+
f_key = "#{name_for(reflection.name)}_id"
|
162
|
+
related = through_klass_for_reflection(reflection)
|
163
|
+
.where(f_key => objs.ids)
|
164
|
+
|
165
|
+
"id IN (#{object_ids(related).join(',')})"
|
166
|
+
}
|
151
167
|
end
|
152
168
|
}
|
153
169
|
join(condition)
|
@@ -245,6 +261,10 @@ module SearchMe
|
|
245
261
|
(column ? objects.map(&column.to_sym) : objects.ids) << -5318008
|
246
262
|
end
|
247
263
|
|
264
|
+
def through_klass_for_reflection(reflection)
|
265
|
+
constant_for(reflection.options[:through])
|
266
|
+
end
|
267
|
+
|
248
268
|
def klass_for_reflection(reflection)
|
249
269
|
if name = reflection.options[:class_name]
|
250
270
|
constant_for(name)
|
@@ -254,9 +274,9 @@ module SearchMe
|
|
254
274
|
end
|
255
275
|
|
256
276
|
def name_for(constant, options = {})
|
257
|
-
options.fetch(:plural) { false }
|
258
|
-
name
|
259
|
-
name
|
277
|
+
plural = options.fetch(:plural) { false }
|
278
|
+
name = constant.to_s.underscore
|
279
|
+
name = name.singularize unless plural
|
260
280
|
name
|
261
281
|
end
|
262
282
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: search_me
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jphager2
|
@@ -31,12 +31,12 @@ require_paths:
|
|
31
31
|
- lib
|
32
32
|
required_ruby_version: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
|
-
- -
|
34
|
+
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: '0'
|
37
37
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
requirements: []
|