query_methods_extend 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/query_methods_extend/like.rb +5 -5
- data/lib/query_methods_extend/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: 92bc332107fea0d943bd445ed9f3449f89852608
|
4
|
+
data.tar.gz: e9c696a7b9f18bf19d010aaa4154f8374651f3b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4e4210ab6236a76cb7735f28d8d36f80084a76c9d2be604010dd362c09f695373965bf2f4f21f06f3ec31a19de95a48adb6a23edac4ad61a8a7e5770d68fce8
|
7
|
+
data.tar.gz: fe68bbc1c89c29289082e48dd41706340d24a3c37128f6d5bf4f2937f78b4b1e23041a4b1c259382e9570a9e05681329e17174ea6ced6a2c54106139e12dfc09
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# QueryMethodsExtend
|
2
2
|
|
3
3
|
Extend query activerecord in rails 4
|
4
|
+
https://rubygems.org/gems/query_methods_extend
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
@@ -147,7 +148,7 @@ SELECT "books".* FROM "books" WHERE (books.price >= 5)
|
|
147
148
|
|
148
149
|
## Contributing
|
149
150
|
|
150
|
-
1. Fork it ( https://github.com/
|
151
|
+
1. Fork it ( https://github.com/alicuche/query_methods_extend/fork )
|
151
152
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
152
153
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
153
154
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -4,22 +4,22 @@ module QueryMethodsExtend
|
|
4
4
|
attr_accessor :extend_like_string
|
5
5
|
|
6
6
|
scope :like, ->(agrs){
|
7
|
-
@extend_like_string = '
|
7
|
+
@extend_like_string = '%{?}%'
|
8
8
|
like_basic agrs
|
9
9
|
}
|
10
10
|
|
11
11
|
scope :l_like, ->(agrs){
|
12
|
-
@extend_like_string = '
|
12
|
+
@extend_like_string = '%{?}'
|
13
13
|
like_basic agrs
|
14
14
|
}
|
15
15
|
|
16
16
|
scope :r_like, ->(agrs){
|
17
|
-
@extend_like_string = '
|
17
|
+
@extend_like_string = '{?}%'
|
18
18
|
like_basic agrs
|
19
19
|
}
|
20
20
|
|
21
21
|
scope :regex_like, ->(agrs){
|
22
|
-
@extend_like_string = '?'
|
22
|
+
@extend_like_string = '{?}'
|
23
23
|
like_basic agrs
|
24
24
|
}
|
25
25
|
|
@@ -28,7 +28,7 @@ module QueryMethodsExtend
|
|
28
28
|
items = self
|
29
29
|
agrs.each do |agr|
|
30
30
|
field, value = agr
|
31
|
-
items = items.where("#{self.table_name}.#{field} LIKE ?", @extend_like_string.gsub('?', value.to_s))
|
31
|
+
items = items.where("#{self.table_name}.#{field} LIKE ?", @extend_like_string.gsub('{?}', value.to_s))
|
32
32
|
end
|
33
33
|
return items
|
34
34
|
else
|