From ec1cac40a761c2d01b73a3081c82fa563c8e768d Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Mon, 15 Jan 2024 15:27:35 +0100 Subject: [PATCH] Fix standardrb violations New standard version, new rules, new fixes. --- .../solidus_friendly_promotions/admin/base_controller.rb | 2 +- .../admin/promotion_rules_controller.rb | 2 +- .../solidus_friendly_promotions/admin/promotion_rules_helper.rb | 2 +- .../rules/line_item_applicable_order_rule.rb | 2 +- .../lib/solidus_friendly_promotions/promotion_migrator.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/promotions/app/controllers/solidus_friendly_promotions/admin/base_controller.rb b/promotions/app/controllers/solidus_friendly_promotions/admin/base_controller.rb index d87386bb..15b483dd 100644 --- a/promotions/app/controllers/solidus_friendly_promotions/admin/base_controller.rb +++ b/promotions/app/controllers/solidus_friendly_promotions/admin/base_controller.rb @@ -7,7 +7,7 @@ def parent @parent ||= self.class.parent_data[:model_class] .includes(self.class.parent_data[:includes]) .find_by!(self.class.parent_data[:find_by] => params["#{parent_model_name}_id"]) - instance_variable_set("@#{parent_model_name}", @parent) + instance_variable_set(:"@#{parent_model_name}", @parent) rescue ActiveRecord::RecordNotFound => e resource_not_found(flash_class: e.model.constantize, redirect_url: routes_proxy.polymorphic_url([:admin, parent_model_name.pluralize.to_sym])) end diff --git a/promotions/app/controllers/solidus_friendly_promotions/admin/promotion_rules_controller.rb b/promotions/app/controllers/solidus_friendly_promotions/admin/promotion_rules_controller.rb index 41d234a1..1be25308 100644 --- a/promotions/app/controllers/solidus_friendly_promotions/admin/promotion_rules_controller.rb +++ b/promotions/app/controllers/solidus_friendly_promotions/admin/promotion_rules_controller.rb @@ -63,7 +63,7 @@ def model_class def validate_promotion_rule_type requested_type = params[:promotion_rule].delete(:type) - promotion_rule_types = SolidusFriendlyPromotions.config.send("#{@level}_rules") + promotion_rule_types = SolidusFriendlyPromotions.config.send(:"#{@level}_rules") @promotion_rule_type = promotion_rule_types.detect do |klass| klass.name == requested_type end diff --git a/promotions/app/helpers/solidus_friendly_promotions/admin/promotion_rules_helper.rb b/promotions/app/helpers/solidus_friendly_promotions/admin/promotion_rules_helper.rb index 2e0bf0a6..ed5e194a 100644 --- a/promotions/app/helpers/solidus_friendly_promotions/admin/promotion_rules_helper.rb +++ b/promotions/app/helpers/solidus_friendly_promotions/admin/promotion_rules_helper.rb @@ -5,7 +5,7 @@ module Admin module PromotionRulesHelper def options_for_promotion_rule_types(promotion_rule, level) existing = promotion_rule.promotion.rules.select(&:persisted?).map { |rule| rule.class.name } - rules = SolidusFriendlyPromotions.config.send("#{level}_rules").reject { |rule| existing.include? rule.name } + rules = SolidusFriendlyPromotions.config.send(:"#{level}_rules").reject { |rule| existing.include? rule.name } options = rules.map { |rule| [rule.model_name.human, rule.name] } options_for_select(options, promotion_rule.type.to_s) end diff --git a/promotions/app/models/concerns/solidus_friendly_promotions/rules/line_item_applicable_order_rule.rb b/promotions/app/models/concerns/solidus_friendly_promotions/rules/line_item_applicable_order_rule.rb index b213c4b3..14dfde0c 100644 --- a/promotions/app/models/concerns/solidus_friendly_promotions/rules/line_item_applicable_order_rule.rb +++ b/promotions/app/models/concerns/solidus_friendly_promotions/rules/line_item_applicable_order_rule.rb @@ -12,7 +12,7 @@ def applicable?(promotable) end def eligible?(promotable) - send("#{promotable.class.name.demodulize.underscore}_eligible?", promotable) + send(:"#{promotable.class.name.demodulize.underscore}_eligible?", promotable) end def level diff --git a/promotions/lib/solidus_friendly_promotions/promotion_migrator.rb b/promotions/lib/solidus_friendly_promotions/promotion_migrator.rb index def52409..c36355bf 100644 --- a/promotions/lib/solidus_friendly_promotions/promotion_migrator.rb +++ b/promotions/lib/solidus_friendly_promotions/promotion_migrator.rb @@ -94,7 +94,7 @@ def generate_new_promotion_rules(old_promotion_rule) else new_rule = new_promo_rule_class.new(old_promotion_rule.attributes.except(*PROMOTION_IGNORED_ATTRIBUTES)) new_rule.preload_relations.each do |relation| - new_rule.send("#{relation}=", old_promotion_rule.send(relation)) + new_rule.send(:"#{relation}=", old_promotion_rule.send(relation)) end [new_rule] end