metova 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/metova.rb +2 -0
- data/lib/metova/models/filterable.rb +30 -0
- data/lib/metova/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjM5ZGQwYzVhYjc4ZTFjODU4Y2NkNWIzNmRiYzI3YWY5MjM1YTNiYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MThhOTlkM2M1NGE5Y2JiMGVmMTMzMmZjNzViMTFhZWZmYmQ1MGVhMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2E4Mzk0YjNjNDkzYWJlOTQyMzdjMzZkNzdiNzBmYjY1ZDA0YTViMDdlZmI1
|
10
|
+
NWE3NDVjMmQzOGJlMDRiNDNmYzBjYzI5YzkzNDZkYzc0ZjMyOTEwMGQ5NDNh
|
11
|
+
NDVhZjc4MWEyNzk2ZTgwY2M1YTZmZDRhN2ExOWIzODUzMWMzMGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2I2NGVjOTY0ZWIxODhhZTBmYjNjNjhkNTQ4N2U3N2I2NGE4ZjU0YjRkMmNj
|
14
|
+
YjAwNzExNGFhZWE0MjhkMjk5MmY4OTVhYTJjNTIzY2I2NTIzOTAwNmQ0YTlm
|
15
|
+
MThmZGJiNDVjOGZiM2IyZGFlZTIxMDNlODU4N2ViYjIyNTY3ZDc=
|
data/lib/metova.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Metova
|
2
|
+
module Models
|
3
|
+
module Filterable
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
def filter_attributes(arg = nil)
|
8
|
+
@filter_attributes = arg if arg
|
9
|
+
@filter_attributes
|
10
|
+
end
|
11
|
+
|
12
|
+
def filter(target, *filter_attrs)
|
13
|
+
if filter_attrs.empty?
|
14
|
+
filter_attrs = @filter_attributes
|
15
|
+
end
|
16
|
+
|
17
|
+
filter_texts = []
|
18
|
+
filter_attrs.each do |attr|
|
19
|
+
filter_texts << "#{attr} like ?"
|
20
|
+
end
|
21
|
+
|
22
|
+
query = [filter_texts.join(' OR ')]
|
23
|
+
filter_texts.count.times { query << "%#{target}%" }
|
24
|
+
|
25
|
+
where(query)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/metova/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metova
|
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
|
- Logan Serman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- lib/metova/error.rb
|
162
162
|
- lib/metova/mandrill.rb
|
163
163
|
- lib/metova/mandrill/railtie.rb
|
164
|
+
- lib/metova/models/filterable.rb
|
164
165
|
- lib/metova/responder.rb
|
165
166
|
- lib/metova/responders/ids_filter_responder.rb
|
166
167
|
- lib/metova/responders/pagination_responder.rb
|