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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 90b1f47c104bb13e62b4cc92703a8dcbaf2dbdfe6c0c9e9a912b43d2a63eb79e
|
|
4
|
+
data.tar.gz: a708e4becdcf314c34c47af4574bd89e4e97985ccb61c2dafcc09889768851d1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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 =
|
|
10
|
-
return helpers.
|
|
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
|
-
|
|
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?(
|
|
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
|
-
**
|
|
131
|
+
**YiffSpace.config.application_controller_class.helpers.data_attributes_for(item),
|
|
132
132
|
}
|
|
133
133
|
end
|
|
134
134
|
end
|
data/lib/yiffspace/version.rb
CHANGED