Fix Performance/StringIdentifierArgument
cop (#28399)
This commit is contained in:
parent
2bd8d343cf
commit
1820bad646
6 changed files with 21 additions and 21 deletions
|
@ -84,7 +84,7 @@ class Form::AdminSettings
|
|||
|
||||
KEYS.each do |key|
|
||||
define_method(key) do
|
||||
return instance_variable_get("@#{key}") if instance_variable_defined?("@#{key}")
|
||||
return instance_variable_get(:"@#{key}") if instance_variable_defined?(:"@#{key}")
|
||||
|
||||
stored_value = if UPLOAD_KEYS.include?(key)
|
||||
SiteUpload.where(var: key).first_or_initialize(var: key)
|
||||
|
@ -94,12 +94,12 @@ class Form::AdminSettings
|
|||
Setting.public_send(key)
|
||||
end
|
||||
|
||||
instance_variable_set("@#{key}", stored_value)
|
||||
instance_variable_set(:"@#{key}", stored_value)
|
||||
end
|
||||
end
|
||||
|
||||
UPLOAD_KEYS.each do |key|
|
||||
define_method("#{key}=") do |file|
|
||||
define_method(:"#{key}=") do |file|
|
||||
value = public_send(key)
|
||||
value.file = file
|
||||
rescue Mastodon::DimensionsValidationError => e
|
||||
|
@ -114,13 +114,13 @@ class Form::AdminSettings
|
|||
return false unless errors.empty? && valid?
|
||||
|
||||
KEYS.each do |key|
|
||||
next unless instance_variable_defined?("@#{key}")
|
||||
next unless instance_variable_defined?(:"@#{key}")
|
||||
|
||||
if UPLOAD_KEYS.include?(key)
|
||||
public_send(key).save
|
||||
else
|
||||
setting = Setting.where(var: key).first_or_initialize(var: key)
|
||||
setting.update(value: typecast_value(key, instance_variable_get("@#{key}")))
|
||||
setting.update(value: typecast_value(key, instance_variable_get(:"@#{key}")))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -139,9 +139,9 @@ class Form::AdminSettings
|
|||
|
||||
def validate_site_uploads
|
||||
UPLOAD_KEYS.each do |key|
|
||||
next unless instance_variable_defined?("@#{key}")
|
||||
next unless instance_variable_defined?(:"@#{key}")
|
||||
|
||||
upload = instance_variable_get("@#{key}")
|
||||
upload = instance_variable_get(:"@#{key}")
|
||||
next if upload.valid?
|
||||
|
||||
upload.errors.each do |error|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue