yiffspace 0.1.1 → 0.1.3

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: 2c5a6f91681f3b27a8a9ae4c3846ce05893cfcfab2ff26387be86ae036a36c3c
4
- data.tar.gz: 1e2897c5ce9d77e00f914e2e2feb968022f0d7c6e8cc08cc779741c2d3f02065
3
+ metadata.gz: 90b1f47c104bb13e62b4cc92703a8dcbaf2dbdfe6c0c9e9a912b43d2a63eb79e
4
+ data.tar.gz: a708e4becdcf314c34c47af4574bd89e4e97985ccb61c2dafcc09889768851d1
5
5
  SHA512:
6
- metadata.gz: 64e931b055288ffd30590af4aa1668684647d915da22c9d9d33cb1f58fabdd452887a7dc96761dfdea8a544334a68966a67821f4a2a7e3726978d2a46ab73695
7
- data.tar.gz: 1715c43fef12acee13bf66a35db09886caff6ef1c77f23690588b04707fcc2649f1d0adc07288bd2c88c72587e61f9102320f42bc18315bf8e0e87e39937ca8d
6
+ metadata.gz: db87381f37b0c7b16ddea8eddfafd6f4e0923b380f1b4a48d5c7359b7867da002309fc7618662596ff57cad975f02efa668feb35b537d8595c9aca0c8ce80312
7
+ data.tar.gz: a2b3501b91f56da362c7de64de11493638600e0ffe0caa7df9eeb2248e8e230bd30c7592cd63108c96d8ab42db70ad017279842bc7a16cc46058ba10f28ea9d3
@@ -26,7 +26,7 @@ module YiffSpace
26
26
  end
27
27
 
28
28
  def statement_timeout
29
- ApplicationRecord.connection.select_one("SELECT setting FROM pg_settings WHERE name = 'statement_timeout'")["setting"].to_i
29
+ YiffSpace.config.application_record_class.connection.select_one("SELECT setting FROM pg_settings WHERE name = 'statement_timeout'")["setting"].to_i
30
30
  end
31
31
 
32
32
  # CrossJoinLateral, LeftJoinLateral, nil
@@ -42,6 +42,14 @@ module YiffSpace
42
42
  # Default: -> { (user_class || ::User).system }
43
43
  attr_writer(:system_user_getter)
44
44
 
45
+ # The application's ApplicationRecord class. Used by Concerns::ActiveRecordExtensions & Utils::TableBuilder.
46
+ # Falls back to ::ApplicationRecord at call time when nil.
47
+ attr_writer(:application_record_class)
48
+
49
+ # The application's ApplicationController class. Used by Utils::Helpers & Utils::TableBuilder.
50
+ # Falls back to ::ApplicationController at call time when nil.
51
+ attr_writer(:application_controller_class)
52
+
45
53
  def initialize
46
54
  @max_multi_count = -> { 100 }
47
55
  @redis_url = -> {}
@@ -93,6 +101,14 @@ module YiffSpace
93
101
  @anonymous_user_name = value.is_a?(Proc) ? value : -> { value }
94
102
  end
95
103
 
104
+ def application_record_class
105
+ @application_record_class || ::ApplicationRecord
106
+ end
107
+
108
+ def application_controller_class
109
+ @application_controller_class || ::ApplicationController
110
+ end
111
+
96
112
  def images
97
113
  @images ||= Images.new
98
114
  end
@@ -5,15 +5,20 @@ module YiffSpace
5
5
  module Helpers
6
6
  module_function
7
7
 
8
+ # Uses send/respond_to?(name, true) (not public_send/respond_to?(name)) because host apps
9
+ # commonly call helpers through this proxy with an explicit receiver (e.g. a decorator's
10
+ # `h.some_helper`), including ones marked private in their helper module - private only
11
+ # restricts calling with an explicit receiver, and normal view rendering (which invokes
12
+ # helpers without one) isn't affected either way.
8
13
  def method_missing(name, *, &)
9
- helpers = ApplicationController.helpers
10
- return helpers.public_send(name, *, &) if helpers.respond_to?(name)
14
+ helpers = YiffSpace.config.application_controller_class.helpers
15
+ return helpers.send(name, *, &) if helpers.respond_to?(name, true)
11
16
 
12
17
  super
13
18
  end
14
19
 
15
20
  def respond_to_missing?(name, include_private = false)
16
- ApplicationController.helpers.respond_to?(name, include_private) || super
21
+ YiffSpace.config.application_controller_class.helpers.respond_to?(name, true) || super
17
22
  end
18
23
  end
19
24
  end
@@ -123,12 +123,12 @@ module YiffSpace
123
123
  # @param _row [Integer] the row number (unused)
124
124
  # @return [Hash] the <tr> attributes
125
125
  def all_row_attributes(item, _row)
126
- return {} unless item.is_a?(ApplicationRecord)
126
+ return {} unless item.is_a?(YiffSpace.config.application_record_class)
127
127
 
128
128
  {
129
129
  id: "#{item.model_name.singular.dasherize}-#{item.id}",
130
130
  **row_attributes,
131
- **ApplicationController.helpers.data_attributes_for(item),
131
+ **YiffSpace.config.application_controller_class.helpers.data_attributes_for(item),
132
132
  }
133
133
  end
134
134
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module YiffSpace
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yiffspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donovan_DMC