facet 0.16.3 → 0.17.4

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: cebdf9f0321fc7a009f565a791ba1f55d1bdb7577c6aa724440c29ace8c1e5aa
4
- data.tar.gz: 2f8f252c205d3b14f27d7788ae0fb4b904fd804a73536e3dc0b4abc6e37b5b17
3
+ metadata.gz: 040065d48def1cb14c2df4ac357a6f0b94376cc643b408e9a7582a5d99cfd2dd
4
+ data.tar.gz: 47689ae773aef5787988305704dc23f9417a7c9b47bab63b0cfa9b24c3b67a49
5
5
  SHA512:
6
- metadata.gz: 1747b4920eb84bdf768518975642625ed33a5206d5c1844045966b1f57e466d7def160fe4e76d5ba9b5ac2d693e8c34b69aec250d9893abf01b85d8b70a05e9f
7
- data.tar.gz: ea179d76cda544852e0fb7be1291bf6131df66cc2d84df72887471d87330716c2b6b652598fadb6c98bb6da737aaf6ddb1e9c9a47e5e49755d8dbdbcb97c86fd
6
+ metadata.gz: 833a9ab8ca87f34851cfb22e8b74ceefa0bf189aefc3d99ae450be961ca6eaa500e7dc8ecc51b06015954a65bf65c4d83befb99f944c967bb1b24ca01b4839e9
7
+ data.tar.gz: 5f1f2991e1cb887ef91679ca1c3663d00256523c4ec1f840815390389c4d329c908197ab958c2ee696e1281c9376f26312416d3b6a9759d413084e957d4dee46
@@ -15,7 +15,7 @@ module Facet
15
15
  end
16
16
 
17
17
  def collection
18
- record_class.public_send(record_scope)
18
+ (source? ? source.public_send(self_scope) : record_class).public_send(record_scope)
19
19
  end
20
20
 
21
21
  def output
@@ -6,13 +6,14 @@ module Facet
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
9
- attr_reader :current_page, :filter_by, :sort_by
9
+ attr_reader :current_page, :filter_by, :sort_by, :source
10
10
  end
11
11
 
12
- def initialize(current_page: nil, filter_by: nil, sort_by: nil, all: false, paginate: true)
12
+ def initialize(current_page: nil, filter_by: nil, sort_by: nil, all: false, paginate: true, source: nil)
13
13
  @current_page = page_for(current_page, paginate)
14
14
  @filter_by = filter_for(filter_by, all)
15
15
  @sort_by = sort_for(sort_by)
16
+ @source = source
16
17
  end
17
18
 
18
19
  def paginated?
@@ -27,6 +28,10 @@ module Facet
27
28
  sort_by.present?
28
29
  end
29
30
 
31
+ def source?
32
+ source.present?
33
+ end
34
+
30
35
  private
31
36
 
32
37
  def page_for(current_page, paginate)
@@ -6,7 +6,7 @@ module Facet
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
9
- delegate :record_class, :record_scope, to: :class
9
+ delegate :record_class, :record_scope, :self_scope, to: :class
10
10
  end
11
11
 
12
12
  class_methods do
@@ -14,6 +14,10 @@ module Facet
14
14
  name.chomp("Facet").constantize
15
15
  end
16
16
 
17
+ def self_scope
18
+ record_class.model_name.collection.to_sym
19
+ end
20
+
17
21
  def record_scope
18
22
  scoped? ? @record_scope : :all
19
23
  end
data/lib/facet/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Facet
4
4
  # This constant is managed by spicerack
5
- VERSION = "0.16.3"
5
+ VERSION = "0.17.4"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.3
4
+ version: 0.17.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Garside
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-19 00:00:00.000000000 Z
11
+ date: 2019-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.16.3
33
+ version: 0.17.4
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.16.3
40
+ version: 0.17.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: short_circu_it
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.16.3
47
+ version: 0.17.4
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.16.3
54
+ version: 0.17.4
55
55
  description: Create cacheable collections of filtered, sorted, and paginated ActiveRecord
56
56
  objects
57
57
  email:
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
96
  requirements: []
97
- rubygems_version: 3.0.3
97
+ rubygems_version: 3.0.6
98
98
  signing_key:
99
99
  specification_version: 4
100
100
  summary: A filterable, sortable, pageable, and Rails cacheable ActiveRecord::Relation