jsonapi-scopes 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0ab9b614b65a6dea7e3255f8093e7efcd4536fcf0ae7fa3c44e693e00940349
4
- data.tar.gz: 6163a1d155fcb233932de0fd0647402e9435712da50238173b156e8f96ca26ad
3
+ metadata.gz: 8d8dcfdd30f2bb38520c1e76e10c0e12207d73b1188d0840ff263927ba5704db
4
+ data.tar.gz: d6ffe6987e5008b220406ce208514437df20ed7aab6e2163ab3ba40bcc35c7db
5
5
  SHA512:
6
- metadata.gz: 7ea31d7bd030d71d7ce5e9d47347042185fef8efb8fca60695d8b55da42d0e75c6bc6e4eed36fd10b12285938f61b506a5318de64d54d4c719040997b1a98ee3
7
- data.tar.gz: 88a612c8da4628d5c0cda2c2d721ef637f38e682f6c3439ca65e392108f53e13efeebd82d7c62a952b7697125796fd75d03761a8c52dbf343c5a66be3b50b71e
6
+ metadata.gz: e5fc34b5769bc7b4d07d036d6a5b61d8ec0ba5d8b4051233c40fecb8024b4b11e080f5946fada23b695e279baef5995f03b706f45853700f923fc8323500c029
7
+ data.tar.gz: 17b004c7009f009e27a54f711e92becd4773bb4bcd73321f924facc1a9738e0c5332a65dc53c22139d84184e9eff9e3ebc2e4c535425b6fa21ba072870d2e1ff
data/README.md CHANGED
@@ -72,6 +72,7 @@ You can use `apply_sort` in your controller :
72
72
  class ContactsController < ApplicationController
73
73
  def index
74
74
  @contacts = Contact.apply_sort(params)
75
+ @contacts = Contact.apply_sort # to only apply default sort
75
76
  end
76
77
  end
77
78
  ```
@@ -9,15 +9,13 @@ module Jsonapi
9
9
  end
10
10
 
11
11
  module ClassMethods
12
- attr_reader :filters
13
-
14
12
  def filter(name, *args)
15
13
  scope(name, *args)
16
14
  @filters << name
17
15
  end
18
16
 
19
17
  def apply_filter(params)
20
- records = self
18
+ records = all
21
19
  filtering_params = params.dig(:filter) || {}
22
20
 
23
21
  filtering_params.each do |key, value|
@@ -18,7 +18,7 @@ module Jsonapi
18
18
  @sortable_fields = fields
19
19
  end
20
20
 
21
- def apply_sort(params, options = { allowed: [], default: {} })
21
+ def apply_sort(params = {}, options = { allowed: [], default: {} })
22
22
  fields = params.dig(:sort)
23
23
 
24
24
  allowed_fields = [options[:allowed]].flatten.presence || @sortable_fields
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jsonapi
4
4
  module Scopes
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-scopes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Briday
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-12 00:00:00.000000000 Z
11
+ date: 2019-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails