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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +19 -1
  3. data/lib/collate/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46caae4fc83f2556a1c2835b951dfb89dd57d557
4
- data.tar.gz: 99278ff861ac8cfb50ba7cdcb1b6ca2940c311ea
3
+ metadata.gz: 984410b26595114259b1b7f04b911e545fcf9c1a
4
+ data.tar.gz: 7c70901aee7e073d5ce119e14c67b219505ec1b2
5
5
  SHA512:
6
- metadata.gz: 070f0611c0adea44f057b62f37d49d93fff18c04ef5681c7638b0491c178908dac17200f5b5966e9f1c10f1971291b7c59b37e4958d35acaa52e42d127531554
7
- data.tar.gz: 5db48b737d9c51c0be11283d74e5e7108f3e1546012c54d8dc969e00e6ff899e60510f3f21e305a8c6ef7d0178d2211b7798c002856fc2f04683f10f3ecf0f5c
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
- collate_on :name
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:
@@ -1,3 +1,3 @@
1
1
  module Collate
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: collate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Page