search_me 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/lib/search_me/search.rb +8 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MDM2MTkwYjU4Y2Q3OTUyOWZjNmU3OTFjZmRmNTdiNDAwYzZiM2Q0Mg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OGNjZGY4MzI0ZDNmYjJlNjljZWYzMjdmMTRhMzBmNjI2YWNiYzJjZA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NDdkYTRkOTA5NTZlOTJkZTgyNzMyZWM3ZmIwNjhiN2JmNWYzNzA2MjYyMDFm
|
10
|
+
NjgwZGQzZDM5MTljMDc1ZjVhNDlkMmFjZjk5YmM1YzUzNzYwMjI0OGUxODM3
|
11
|
+
ZTE0NzA3MTZlNzg3NzRmNGU2OWRiNjg5YWI3OTM0MzExYzhjOGM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
Mzc1YTU0OTdiN2IwOWI0YzMzMDE1YzRlMWM4ZTc1MmZjYTMwZGE0MDA1Yjc1
|
14
|
+
ODc0OWMwMWUzODIzNjAxOGYyN2ZiODFjNzEwYjNjNGQyY2VjZjQyOWJlZjU0
|
15
|
+
N2U1MWU0MjQzMWZiN2NjYzY1OWFhNWJjZjZiZjA0NDY2ODdiYTg=
|
data/lib/search_me/search.rb
CHANGED
@@ -14,7 +14,10 @@ module SearchMe
|
|
14
14
|
}
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
# assuming the last attribute could be a hash
|
18
|
+
def attr_search(*attributes)
|
19
|
+
options = attributes.last.is_a?(Hash) ? attributes.pop : {}
|
20
|
+
type = options.fetch(:type) { :simple }
|
18
21
|
unless ([:simple] + self.reflections.keys).include?(type)
|
19
22
|
raise ArgumentError, 'incorect type given'
|
20
23
|
end
|
@@ -22,7 +25,8 @@ module SearchMe
|
|
22
25
|
search_attributes_hash!(attributes, type, search_attributes)
|
23
26
|
end
|
24
27
|
|
25
|
-
def alias_advanced_search(attribute,
|
28
|
+
def alias_advanced_search(attribute, options = {}, &block)
|
29
|
+
type = options.fetch(:type) { :simple }
|
26
30
|
advanced_search_blocks[type][attribute] = block
|
27
31
|
end
|
28
32
|
|
@@ -249,7 +253,8 @@ module SearchMe
|
|
249
253
|
end
|
250
254
|
end
|
251
255
|
|
252
|
-
def name_for(constant,
|
256
|
+
def name_for(constant, options = {})
|
257
|
+
options.fetch(:plural) { false }
|
253
258
|
name = constant.to_s.underscore
|
254
259
|
name = name.singularize unless plural
|
255
260
|
name
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jphager2
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Uses LIKE to search attributes and return any objects of the model for
|
14
14
|
which a match is found
|
@@ -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: []
|