katalyst-tables 3.11.0 → 3.11.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '058d981c1598d836b758da0286de162feed139ae80aa1b59465a4505bd3ef0e2'
4
- data.tar.gz: ed95bb712fdf61560678659121b5a368839830ae3577eca4ae9d4c98d04f5b6c
3
+ metadata.gz: 9729837e84361c855acdd0d23b3c516cea8f23e0d35efdd6508c9a18b9b63119
4
+ data.tar.gz: a0a53bc4ae518f42c208489ddfdc0afb8ef7449db1723fcac9a40ccf2efadaae
5
5
  SHA512:
6
- metadata.gz: a24284360f7f865e46001614c877a4564c87b2c6a197a94ece8430d55ac1aa14b49d5f86be1b7304f662c56418b0d288e8ddfc8933298277b7579c0eff1042f5
7
- data.tar.gz: e6cb76f7383fb3a146465701b2842ebe54f4e0352e6fd0fb0d88ea83c9c397de7789b66fdf8d1e589fafcef78a50f3063a359b9e588bf88422e8797fa38a8f3d
6
+ metadata.gz: bd459c5d5fa680739a8076f4fb9a7ac23fa99a7ccf3acb4a0be27a4510daa08008707f24034b18ca31aaf7883ee5439be0d690ab920bc517e1400193f8855d50
7
+ data.tar.gz: 06344beea9462b8eb4772baf662755f718d0a66c55407c8e52e3b70a6fe1f2a2a12f900a9fe3cc870a262aa9fc86ca5ddc9d15640f43826dc1ea3d08dc583b9a
@@ -3,18 +3,25 @@
3
3
  module Katalyst
4
4
  module Tables
5
5
  module Collection
6
+ class Config
7
+ attr_accessor :paginate, :sorting
8
+ end
9
+
6
10
  module Core # :nodoc:
7
11
  extend ActiveSupport::Concern
8
12
 
9
13
  include ActiveModel::Model
10
14
  include ActiveModel::Attributes
11
15
  include ActiveModel::Dirty
12
- include ActiveSupport::Configurable
13
16
 
14
17
  include HasParams
15
18
  include Reducers
16
19
 
17
20
  class_methods do
21
+ def config
22
+ @config ||= Config.new
23
+ end
24
+
18
25
  def permitted_params
19
26
  _default_attributes.to_h.each_with_object([]) do |(k, v), h|
20
27
  h << case v
@@ -20,11 +20,9 @@ module Katalyst
20
20
  attr_accessor :pagination
21
21
 
22
22
  attribute :page, :integer, default: 1, filter: false
23
-
24
- config_accessor :paginate
25
23
  end
26
24
 
27
- def initialize(paginate: config.paginate, **)
25
+ def initialize(paginate: self.class.config.paginate, **)
28
26
  super(**)
29
27
 
30
28
  @paginate = paginate.freeze
@@ -50,8 +48,8 @@ module Katalyst
50
48
  # Expect to see NoMethodError failures if pagy is not available
51
49
  if (pagy_method = "Pagy::Method".safe_constantize)
52
50
  include(pagy_method)
53
- else
54
- "Pagy::Backend".safe_constantize&.tap { |pagy| include(pagy) }
51
+ elsif (pagy_backend = "Pagy::Backend".safe_constantize)
52
+ include(pagy_backend)
55
53
  end
56
54
 
57
55
  def initialize(app)
@@ -68,7 +66,7 @@ module Katalyst
68
66
 
69
67
  # pagy shim
70
68
  def params
71
- @collection.to_params
69
+ @collection.to_params.with_indifferent_access
72
70
  end
73
71
 
74
72
  # Pagy 43 expects a request object; provide the minimal hash interface it supports.
@@ -55,7 +55,7 @@ module Katalyst
55
55
  attr_reader :default_sort
56
56
  end
57
57
 
58
- def initialize(sorting: config.sorting, **)
58
+ def initialize(sorting: self.class.config.sorting, **)
59
59
  @default_sort = sorting.to_param if sorting.present?
60
60
 
61
61
  super(sort: @default_sort, **) # set default sort based on config
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katalyst-tables
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.0
4
+ version: 3.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katalyst Interactive