From 15e172e314b4d8d94ad6ab9123da8b3bc4556165 Mon Sep 17 00:00:00 2001 From: andrea longhi Date: Fri, 20 Nov 2020 12:48:09 +0100 Subject: [PATCH] Avoid `#method` shadowing Ruby already defines the method `#method`, so variables and parameters are renamed in order to avoid shadowing that method. --- core/app/models/spree/calculator.rb | 8 ++++---- core/app/models/spree/order/payments.rb | 4 ++-- core/lib/spree/permitted_attributes.rb | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/app/models/spree/calculator.rb b/core/app/models/spree/calculator.rb index 2773570b1b..3d9bf4a0cc 100644 --- a/core/app/models/spree/calculator.rb +++ b/core/app/models/spree/calculator.rb @@ -10,12 +10,12 @@ class Calculator < Spree::Base def compute(computable) # Spree::LineItem -> :compute_line_item computable_name = computable.class.name.demodulize.underscore - method = "compute_#{computable_name}".to_sym + method_name = "compute_#{computable_name}".to_sym calculator_class = self.class - if respond_to?(method) - send(method, computable) + if respond_to?(method_name) + send(method_name, computable) else - raise NotImplementedError, "Please implement '#{method}(#{computable_name})' in your calculator: #{calculator_class.name}" + raise NotImplementedError, "Please implement '#{method_name}(#{computable_name})' in your calculator: #{calculator_class.name}" end end diff --git a/core/app/models/spree/order/payments.rb b/core/app/models/spree/order/payments.rb index 0c5a2a66fb..6891bd4c7b 100644 --- a/core/app/models/spree/order/payments.rb +++ b/core/app/models/spree/order/payments.rb @@ -37,14 +37,14 @@ def unprocessed_payments private - def process_payments_with(method) + def process_payments_with(method_name) # Don't run if there is nothing to pay. return true if payment_total >= total unprocessed_payments.each do |payment| break if payment_total >= total - payment.public_send(method) + payment.public_send(method_name) end rescue Core::GatewayError => error result = !!Spree::Config[:allow_checkout_on_gateway_error] diff --git a/core/lib/spree/permitted_attributes.rb b/core/lib/spree/permitted_attributes.rb index 52daf04bec..d3578aa745 100644 --- a/core/lib/spree/permitted_attributes.rb +++ b/core/lib/spree/permitted_attributes.rb @@ -191,12 +191,12 @@ def prepend(*attributes) private - def inject_attributes_to_all_steps(attributes, method) + def inject_attributes_to_all_steps(attributes, method_name) attributes.each do |attribute| - PermittedAttributes.checkout_address_attributes.send(method, attribute) - PermittedAttributes.checkout_delivery_attributes.send(method, attribute) - PermittedAttributes.checkout_payment_attributes.send(method, attribute) - PermittedAttributes.checkout_confirm_attributes.send(method, attribute) + PermittedAttributes.checkout_address_attributes.send(method_name, attribute) + PermittedAttributes.checkout_delivery_attributes.send(method_name, attribute) + PermittedAttributes.checkout_payment_attributes.send(method_name, attribute) + PermittedAttributes.checkout_confirm_attributes.send(method_name, attribute) end end end