filta 0.5.0 → 0.6.1
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 +7 -3
- data/VERSION +1 -1
- data/lib/filta/methods.rb +9 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6f7c7b008c76c763d91d697460e4265d36bece571bb49c13e4e77c18a460715
|
4
|
+
data.tar.gz: 0c999a1fcda30565db120ae3b2e5aeff6b488422a519c8383d5022e4a2b19dc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a48a978fc3f808a84c013e31b54927dde0a7acba771b4aaf66dd60e2dfd48dc5465ae27a500db345b88ef431679dd382d0883e9b3359b3200317246feac18ac5
|
7
|
+
data.tar.gz: 65b963491fba5d459af30afa9f6819af2154f0988933429d116a98e7feb0c9ad04b4242e5ef110b3b8fc976889e0f863df3d4b53041b9a019d53d5dfbe53b2db
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Super simple filtering for ActiveRecord, inspired by [Justin Weiss' Gist](https://gist.github.com/justinweiss/9065666).
|
4
4
|
|
5
5
|
[](https://badge.fury.io/rb/filta)
|
6
|
-
[](https://travis-ci.org/sleepingstu/filta)
|
7
7
|
|
8
8
|
<!-- MarkdownTOC -->
|
9
9
|
|
@@ -39,17 +39,21 @@ $ gem install filta
|
|
39
39
|
Use like you would any other kind of ActiveRecord scope.
|
40
40
|
|
41
41
|
```ruby
|
42
|
-
@filtered = Klass.
|
42
|
+
@filtered = Klass.filta({ title: "Foo", something: "Bar" })
|
43
43
|
```
|
44
44
|
|
45
45
|
The `filter` method returns an ActiveRecord relation so you can chain the calls with other methods.
|
46
46
|
|
47
47
|
```ruby
|
48
|
-
Klass.
|
48
|
+
Klass.filta({ title: "Foo" }).order("created_at DESC")
|
49
49
|
```
|
50
50
|
|
51
51
|
If using in a controller make sure you use the `params.permit` method to sanitise what you pass into the `filter` method.
|
52
52
|
|
53
|
+
## Notes
|
54
|
+
|
55
|
+
The original `.filter` method is deprecated to avoid any confusion
|
56
|
+
|
53
57
|
|
54
58
|
## Contributing
|
55
59
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.1
|
data/lib/filta/methods.rb
CHANGED
@@ -7,15 +7,22 @@ module Filta
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module ClassMethods
|
10
|
-
def
|
10
|
+
def filta(by)
|
11
11
|
results = where(nil)
|
12
12
|
|
13
13
|
by.each do |key, value|
|
14
|
-
|
14
|
+
next unless value.present?
|
15
|
+
|
16
|
+
results = results.where(key.to_s.to_sym => value)
|
15
17
|
end
|
16
18
|
|
17
19
|
results
|
18
20
|
end
|
21
|
+
|
22
|
+
# TODO: This method is now deprecated and should be removed at a later date
|
23
|
+
def filter(by)
|
24
|
+
filta(by)
|
25
|
+
end
|
19
26
|
end
|
20
27
|
end
|
21
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Chinery
|
8
|
+
- Lorenzo Tello
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2019-
|
12
|
+
date: 2019-08-01 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rails
|
@@ -16,14 +17,14 @@ dependencies:
|
|
16
17
|
requirements:
|
17
18
|
- - "~>"
|
18
19
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
20
|
+
version: '5.2'
|
20
21
|
type: :runtime
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
25
|
- - "~>"
|
25
26
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
27
|
+
version: '5.2'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
29
|
name: minitest
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -69,7 +70,7 @@ dependencies:
|
|
69
70
|
description: Super simple filtering for ActiveRecord, inspired by Justin Weiss' Gist
|
70
71
|
- https://gist.github.com/justinweiss/9065666
|
71
72
|
email:
|
72
|
-
-
|
73
|
+
- developers@boxt.co.uk
|
73
74
|
executables: []
|
74
75
|
extensions: []
|
75
76
|
extra_rdoc_files: []
|
@@ -101,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
102
|
- !ruby/object:Gem::Version
|
102
103
|
version: '0'
|
103
104
|
requirements: []
|
104
|
-
rubygems_version: 3.0.
|
105
|
+
rubygems_version: 3.0.3
|
105
106
|
signing_key:
|
106
107
|
specification_version: 4
|
107
108
|
summary: Super simple filtering for ActiveRecord
|