metova 0.0.4 → 0.0.5

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTAzNDQ4ODgwZWY4ODcyYWMyNzk2OGNjYmI2M2YxZTgyYTE2NzYxOA==
4
+ YjM5ZGQwYzVhYjc4ZTFjODU4Y2NkNWIzNmRiYzI3YWY5MjM1YTNiYg==
5
5
  data.tar.gz: !binary |-
6
- Y2IzM2I1MTI1MDE0YzFhZGEwNGNhMzU2MTllOTI0YTMwZmE2OWQ3Nw==
6
+ MThhOTlkM2M1NGE5Y2JiMGVmMTMzMmZjNzViMTFhZWZmYmQ1MGVhMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODE0NGM5ZTQ0NjE4NjcyZDJlYWY5ZDU2NGIzZTBjMzUzODA3NjY4YjViMWJj
10
- NDI4YzBmYmY1N2YzNmQ4ZmY0ZDBiMzQwZjE4MmU5NzFhNDZlNTNhYWJkMjhm
11
- NTMxNjEzNjAzYjU5NmRmYWYzMGIyNDUzY2U4NzU2MzJiZDA2ODc=
9
+ M2E4Mzk0YjNjNDkzYWJlOTQyMzdjMzZkNzdiNzBmYjY1ZDA0YTViMDdlZmI1
10
+ NWE3NDVjMmQzOGJlMDRiNDNmYzBjYzI5YzkzNDZkYzc0ZjMyOTEwMGQ5NDNh
11
+ NDVhZjc4MWEyNzk2ZTgwY2M1YTZmZDRhN2ExOWIzODUzMWMzMGE=
12
12
  data.tar.gz: !binary |-
13
- MzMwNjY5Yzc4M2IzMjdhNzQ3YjQ0MDJlZjBlNTczZmZjOGY2NDY1ZDYyZWJh
14
- NWQ2NTA2NzRkNTdlNzVjZTI5YzdkNTg2NGJkNDcyZTBkZmJmZTU5Mzk0ZTE1
15
- NTc5YjgzYmJjYTMwYTU3OWJlM2YzMGM1NTIxY2FjYjQ5ZWMzYTE=
13
+ M2I2NGVjOTY0ZWIxODhhZTBmYjNjNjhkNTQ4N2U3N2I2NGE4ZjU0YjRkMmNj
14
+ YjAwNzExNGFhZWE0MjhkMjk5MmY4OTVhYTJjNTIzY2I2NTIzOTAwNmQ0YTlm
15
+ MThmZGJiNDVjOGZiM2IyZGFlZTIxMDNlODU4N2ViYjIyNTY3ZDc=
data/lib/metova.rb CHANGED
@@ -15,5 +15,7 @@ require 'metova/devise/controller'
15
15
  require 'metova/devise/strategies/token_authenticatable'
16
16
  require 'metova/devise/models/token_authenticatable'
17
17
 
18
+ require 'metova/models/filterable'
19
+
18
20
  module Metova
19
21
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Metova
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
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
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 00:00:00.000000000 Z
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