Skip to content

Commit

Permalink
Merge pull request #3846 from nebulab/spaghetticode/shadow-method
Browse files Browse the repository at this point in the history
Avoid `#method` shadowing
  • Loading branch information
aldesantis authored Nov 27, 2020
2 parents faa7422 + 15e172e commit 47dacba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions core/app/models/spree/calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions core/app/models/spree/order/payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 5 additions & 5 deletions core/lib/spree/permitted_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 47dacba

Please sign in to comment.