-
-
Notifications
You must be signed in to change notification settings - Fork 725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Favor #public_send over #send using Rubocop's cop #2618
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ def ng_form_for(name, *args, &block) | |
# spree.foo_path in any view rendered from non-spree-namespaced controllers. | ||
def method_missing(method, *args, &block) | ||
if (method.to_s.end_with?('_path') || method.to_s.end_with?('_url')) && spree.respond_to?(method) | ||
spree.send(method, *args) | ||
spree.public_send(method, *args) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rails' URL helpers are public |
||
else | ||
super | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ def initialize(klass, collection, attributes={}, reject_if=nil, delete_if=nil) | |
@collection = attributes[:collection] if attributes[:collection] | ||
|
||
attributes.each do |name, value| | ||
send("#{name}=", value) | ||
public_send("#{name}=", value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the setters of a model are meant to be public |
||
end | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ class ProxyOrder < ActiveRecord::Base | |
def state | ||
# NOTE: the order is important here | ||
%w(canceled paused pending cart).each do |state| | ||
return state if send("#{state}?") | ||
return state if __send__("#{state}?") | ||
end | ||
order.state | ||
end | ||
|
@@ -32,7 +32,7 @@ def cancel | |
return false unless order_cycle.orders_close_at.andand > Time.zone.now | ||
transaction do | ||
update_column(:canceled_at, Time.zone.now) | ||
order.send('cancel') if order | ||
order.cancel if order | ||
true | ||
end | ||
end | ||
|
@@ -41,7 +41,7 @@ def resume | |
return false unless order_cycle.orders_close_at.andand > Time.zone.now | ||
transaction do | ||
update_column(:canceled_at, nil) | ||
order.send('resume') if order | ||
order.resume if order | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these two methods are public |
||
true | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,7 +83,7 @@ def relevant_address_attrs | |
|
||
def addresses_match?(order_address, subscription_address) | ||
relevant_address_attrs.all? do |attr| | ||
order_address[attr] == subscription_address.send("#{attr}_was") || | ||
order_address[attr] == subscription_address.public_send("#{attr}_was") || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AR's dirty attributes API is public |
||
order_address[attr] == subscription_address[attr] | ||
end | ||
end | ||
|
@@ -101,7 +101,7 @@ def ship_address_updatable?(order) | |
# address on the order matches the shop's address | ||
def force_ship_address_required?(order) | ||
return false unless shipping_method.require_ship_address? | ||
distributor_address = order.send(:address_from_distributor) | ||
distributor_address = order.__send__(:address_from_distributor) | ||
relevant_address_attrs.all? do |attr| | ||
order.ship_address[attr] == distributor_address[attr] | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ def self.parse(payload, sso_secret = nil) | |
if BOOLS.include? k | ||
val = ["true", "false"].include?(val) ? val == "true" : nil | ||
end | ||
sso.send("#{k}=", val) | ||
sso.public_send("#{k}=", val) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. each of these K are defined as public attr_accessor in line 11 |
||
end | ||
|
||
decoded_hash.each do |k,v| | ||
|
@@ -87,9 +87,9 @@ def payload | |
def unsigned_payload | ||
payload = {} | ||
ACCESSORS.each do |k| | ||
next if (val = send k) == nil | ||
next if (val = public_send k) == nil | ||
|
||
payload[k] = val | ||
payload[k] = val | ||
end | ||
|
||
if @custom_fields | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this one public. If we use it from outside, it's part of applicator's public API