maintenance_tasks 2.5.0 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/maintenance_tasks/tasks_helper.rb +22 -7
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8952908cba45fd0a79cfcf0d334e89eab4e3a554ba4c0b1acffb318c7e92730f
|
4
|
+
data.tar.gz: bc1312f6269c51fe80480f7af90281c89c36bc9c78f052f65f4b5853effa5a41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c32f23abae224617aef9148ac7e890a95fb799997e0900b6a5ad72fbb988cadb25ef61ef6a35e803f2483cce93f6ad20d379c202f2a513f72c339d553e830a12
|
7
|
+
data.tar.gz: cead5f36f1038614e23da3c6fa3661be58d00ac326a859681a3740d818977f0c3c311860f567d96701dcd04bc1019e001ad0903c20833444b2a0669dd9aac6e9
|
@@ -101,16 +101,31 @@ module MaintenanceTasks
|
|
101
101
|
)
|
102
102
|
end
|
103
103
|
|
104
|
-
#
|
105
|
-
#
|
106
|
-
|
107
|
-
|
104
|
+
# Resolves values covered by the inclusion validator for a task attribute.
|
105
|
+
# Only Arrays are supported, option types such as:
|
106
|
+
# Procs, lambdas, symbols, and Range are not supported and return nil.
|
107
|
+
#
|
108
|
+
# Returned values are used to populate a dropdown list of options.
|
109
|
+
#
|
110
|
+
# @param task_class [Class<Task>] The task class for which the value needs to be resolved.
|
111
|
+
# @param parameter_name [String] The parameter name.
|
112
|
+
#
|
113
|
+
# @return [Array] value of the resolved inclusion option.
|
114
|
+
def resolve_inclusion_value(task_class, parameter_name)
|
115
|
+
inclusion_validator = task_class.validators_on(parameter_name).find do |validator|
|
108
116
|
validator.kind == :inclusion
|
109
117
|
end
|
118
|
+
return unless inclusion_validator
|
110
119
|
|
111
|
-
|
112
|
-
|
113
|
-
|
120
|
+
in_option = inclusion_validator.options[:in] || inclusion_validator.options[:within]
|
121
|
+
in_option if in_option.is_a?(Array)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Return the appropriate field tag for the parameter, based on its type.
|
125
|
+
# If the parameter has a `validates_inclusion_of` validator, return a dropdown list of options instead.
|
126
|
+
def parameter_field(form_builder, parameter_name)
|
127
|
+
inclusion_values = resolve_inclusion_value(form_builder.object.class, parameter_name)
|
128
|
+
return form_builder.select(parameter_name, inclusion_values, prompt: "Select a value") if inclusion_values
|
114
129
|
|
115
130
|
case form_builder.object.class.attribute_types[parameter_name]
|
116
131
|
when ActiveModel::Type::Integer
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maintenance_tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -171,7 +171,7 @@ homepage: https://github.com/Shopify/maintenance_tasks
|
|
171
171
|
licenses:
|
172
172
|
- MIT
|
173
173
|
metadata:
|
174
|
-
source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v2.5.
|
174
|
+
source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v2.5.1
|
175
175
|
allowed_push_host: https://rubygems.org
|
176
176
|
post_install_message:
|
177
177
|
rdoc_options: []
|
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
188
|
- !ruby/object:Gem::Version
|
189
189
|
version: '0'
|
190
190
|
requirements: []
|
191
|
-
rubygems_version: 3.5.
|
191
|
+
rubygems_version: 3.5.6
|
192
192
|
signing_key:
|
193
193
|
specification_version: 4
|
194
194
|
summary: A Rails engine for queuing and managing maintenance tasks
|