activerecord-search 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/activerecord/base.rb +12 -2
- data/lib/activerecord/search/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 217894347fbc21e9e8da4a2f689545b07e40d686
|
4
|
+
data.tar.gz: 65347e45036d075da50cbb653c649c787a2c5241
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d46b3eab25c60f7f1efac04c6888331fbf154dffbca141e353a4f6afccc31b08dc90c59867f86cb48bff6bf241a5c23f5a330a684874da904d6714eda8c7651
|
7
|
+
data.tar.gz: ab40537696a950a5f04cf8be2c60e6ac6cafc788819ddb0f803a13c89842e6829200e3dde031659f47873f983197f9a5802ffb33aff162fed8c4d3756247da7d
|
data/lib/activerecord/base.rb
CHANGED
@@ -32,13 +32,23 @@ module ActiveRecord
|
|
32
32
|
where([search_scope.join(" OR "), search_params])
|
33
33
|
end
|
34
34
|
|
35
|
+
def start_with(words)
|
36
|
+
search_#{subclass.to_s.underscore}(words, :start_with)
|
37
|
+
end
|
38
|
+
|
39
|
+
def end_with(words)
|
40
|
+
search_#{subclass.to_s.underscore}(words, :end_with)
|
41
|
+
end
|
42
|
+
|
43
|
+
def search_anywhere(words)
|
44
|
+
search_#{subclass.to_s.underscore}(words, :anywhere)
|
45
|
+
end
|
46
|
+
|
35
47
|
def search_fields(fields)
|
36
48
|
@search_fields = [fields].flatten
|
37
49
|
end
|
38
50
|
alias_method :search_field, :search_fields
|
39
51
|
|
40
|
-
|
41
|
-
# If options are given, they override the default options behavior
|
42
52
|
def format_search(words, option)
|
43
53
|
if !option.nil?
|
44
54
|
format_with_option(words, option)
|