filta 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/filta.rb +9 -0
- data/lib/filta/methods.rb +21 -0
- data/lib/filta/version.rb +3 -0
- data/lib/tasks/filta.rake +4 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc34f7efbbf6feb66689560ffccbaf7bca8d1e83
|
4
|
+
data.tar.gz: 231d66d87ff55f49eb73056fcdc478c5344b6763
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25bed89dd3ba7f78310aee7db5c989e02b3368e5ae95fb3adf0b4c3e9fb02866810541339f8881d302d12e7792863edb737bbccb4bd54bf77c42c1e708296ff4
|
7
|
+
data.tar.gz: 30db3e608cc2e9733fca78859abbda449a26de13a097f7beed2f7a11f568d279dcfd8da02a42d84efcd297556ba1327c85395286f13ddccb752aa11809974ccf
|
data/README.md
CHANGED
@@ -8,6 +8,7 @@ Super simple filtering for ActiveRecord, inspired by [Justin Weiss' Gist](https:
|
|
8
8
|
- [Installation](#installation)
|
9
9
|
- [Contributing](#contributing)
|
10
10
|
- [License](#license)
|
11
|
+
- [TODO](#todo)
|
11
12
|
|
12
13
|
<!-- /MarkdownTOC -->
|
13
14
|
|
@@ -49,3 +50,7 @@ $ gem install filta
|
|
49
50
|
## License
|
50
51
|
|
51
52
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
53
|
+
|
54
|
+
## TODO
|
55
|
+
|
56
|
+
* Finish README
|
data/lib/filta.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Filta
|
2
|
+
module Methods
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
base.extend ClassMethods
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
def filter(by)
|
10
|
+
results = self.where(nil)
|
11
|
+
|
12
|
+
by.each do |key, value|
|
13
|
+
results = results.where("#{key} = ?", value) if value.present?
|
14
|
+
end
|
15
|
+
|
16
|
+
results
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Chinery
|
@@ -77,6 +77,10 @@ files:
|
|
77
77
|
- MIT-LICENSE
|
78
78
|
- README.md
|
79
79
|
- Rakefile
|
80
|
+
- lib/filta.rb
|
81
|
+
- lib/filta/methods.rb
|
82
|
+
- lib/filta/version.rb
|
83
|
+
- lib/tasks/filta.rake
|
80
84
|
homepage: https://github.com/sleepingstu/filta
|
81
85
|
licenses:
|
82
86
|
- MIT
|