collate 0.1.0 → 0.1.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 +19 -1
- data/lib/collate/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 984410b26595114259b1b7f04b911e545fcf9c1a
|
4
|
+
data.tar.gz: 7c70901aee7e073d5ce119e14c67b219505ec1b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c53dd532b38d172b5b278c80c073b5dfec8c306d2fa31db7e57aaa66afceff938f0f3be70437edfc574ece0dabdba9cb1bfb2f167ddc66f2f2967ad32c252d7
|
7
|
+
data.tar.gz: 8e9a7c5e833e0f6e5a627ebcc78b9286676b7a0fdacfa4c14219e8d387867fd05da2b2ce51c5c87afa01489d1c581c31e26b30769e94f7b5392f3539e49eda04
|
data/README.md
CHANGED
@@ -20,11 +20,29 @@ This gem currently only supports PostgreSQL.
|
|
20
20
|
To use collate in a model, include several collation definitions. The first argument is the name of the database column to use in the query. The simplest example looks like this:
|
21
21
|
|
22
22
|
```
|
23
|
-
|
23
|
+
class Person < ActiveRecord::Base
|
24
|
+
collate_on :name
|
25
|
+
end
|
24
26
|
```
|
25
27
|
|
26
28
|
This will add a filter to the model that will grab all records where the ```name``` column equals the parameter that is passed in.
|
27
29
|
|
30
|
+
Then you only need to use the ```collate``` method in the controller, passing the params:
|
31
|
+
|
32
|
+
```
|
33
|
+
@people = Person.collate(params)
|
34
|
+
```
|
35
|
+
|
36
|
+
The params key needs to match the key that the gem is expecting. You can currently find out what that key is by iterating over the ```collate_filters``` hash on the model's class, or you can create a filter that matches the definition in the model, and grab the param_key like this:
|
37
|
+
|
38
|
+
```
|
39
|
+
filter = Collate::Filter.new(:name, base_model_table_name: "people")
|
40
|
+
|
41
|
+
params[filter.param_key] = 'John Doe'
|
42
|
+
|
43
|
+
@people = Person.collate(params)
|
44
|
+
```
|
45
|
+
|
28
46
|
### Operators
|
29
47
|
|
30
48
|
You can currently collate using multiple types of operators. To specify an operator to collate on, you can pass in the keyword argument ```operator```, like this:
|
data/lib/collate/version.rb
CHANGED