simple_searchable 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +1 -1
- data/lib/simple_searchable.rb +5 -5
- data/lib/simple_searchable/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1d3020aac43ae13fb33ab6f44c1d9f229b69ebfd1fad8972a425377568457639
|
4
|
+
data.tar.gz: 9f82455b3d396362c5ba07d5842b29c0041dec6d110c8cd08caf2c2e28c86238
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc43b4ba70c43f9311536faf23ec1f764a5a73ebc826094d4e413176556545c8714932e549a0c5c1d4988192a1f7cc0a406290dc9a39e0e634e7631ed17f71a1
|
7
|
+
data.tar.gz: cf465e33ccc49c43f8106ede96e1884f654a998a3bc3324579bc7e4a914fe17784e5d486a325f0af9589d865336737a084ce49d2ba4559c715a460e42f8cd556
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# SimpleSearchable
|
2
2
|
|
3
|
-
This gem adds the utility methods for a basic ActiveRecord search/filtering pattern
|
3
|
+
This gem adds the utility methods for a basic ActiveRecord search/filtering pattern.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
data/lib/simple_searchable.rb
CHANGED
@@ -6,23 +6,23 @@ module SimpleSearchable
|
|
6
6
|
self.singleton_class.send(:define_method, :search) do |opts|
|
7
7
|
return all if opts.nil?
|
8
8
|
|
9
|
-
|
9
|
+
search_filter_all(method_names, opts)
|
10
10
|
end
|
11
11
|
|
12
12
|
self.send(:extend, FilterMethods)
|
13
13
|
end
|
14
14
|
|
15
15
|
module FilterMethods
|
16
|
-
def
|
16
|
+
def search_filter(name, arg)
|
17
17
|
arg.present? ? send(name, arg) : all
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
20
|
+
def search_filter_all(names, opts)
|
21
21
|
result = self.all
|
22
22
|
names.each do |n|
|
23
23
|
unless opts[n].blank?
|
24
24
|
opts[n].reject!(&:blank?) if opts[n].is_a?(Array)
|
25
|
-
result = result.
|
25
|
+
result = result.search_filter(n, opts[n])
|
26
26
|
end
|
27
27
|
end
|
28
28
|
result
|
@@ -31,4 +31,4 @@ module SimpleSearchable
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
ActiveRecord::Base.send(:extend, SimpleSearchable::SearchableBy)
|
34
|
+
ActiveRecord::Base.send(:extend, SimpleSearchable::SearchableBy)
|
metadata
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_searchable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Campbell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "<"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '6'
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: '4.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "<"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '6'
|
30
27
|
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: '4.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
95
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.7.8
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: A very simple ActiveRecord search pattern
|