mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:12:45 +08:00
DEV: move send => public_send in lib folder
This handles most of the cases in `lib` where we were using send instead of public_send
This commit is contained in:
parent
451f7842ff
commit
e2bcf55077
|
@ -2,7 +2,7 @@ class Auth::AuthProvider
|
|||
include ActiveModel::Serialization
|
||||
|
||||
def initialize(params = {})
|
||||
params.each { |key, value| send "#{key}=", value }
|
||||
params.each { |key, value| public_send "#{key}=", value }
|
||||
end
|
||||
|
||||
def self.auth_attributes
|
||||
|
|
|
@ -14,7 +14,7 @@ class ComposerMessagesFinder
|
|||
return if editing_post?
|
||||
|
||||
self.class.check_methods.each do |m|
|
||||
msg = send(m)
|
||||
msg = public_send(m)
|
||||
return msg if msg.present?
|
||||
end
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ module ActiveSupport
|
|||
found = true
|
||||
data = cache.fetch(arguments) { found = false }
|
||||
unless found
|
||||
cache[arguments] = data = send(uncached, *arguments)
|
||||
cache[arguments] = data = public_send(uncached, *arguments)
|
||||
end
|
||||
# so cache is never corrupted
|
||||
data.dup
|
||||
|
@ -48,7 +48,7 @@ module ActiveSupport
|
|||
|
||||
define_method(method_name) do |*arguments|
|
||||
ActiveSupport::Inflector.clear_memoize!
|
||||
send(orig, *arguments)
|
||||
public_send(orig, *arguments)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -118,7 +118,7 @@ class Guardian
|
|||
def can_see?(obj)
|
||||
if obj
|
||||
see_method = method_name_for :see, obj
|
||||
return (see_method ? send(see_method, obj) : true)
|
||||
return (see_method ? public_send(see_method, obj) : true)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -137,7 +137,7 @@ class Guardian
|
|||
end
|
||||
create_method = :"can_create_#{target}?"
|
||||
|
||||
return send(create_method, parent) if respond_to?(create_method)
|
||||
return public_send(create_method, parent) if respond_to?(create_method)
|
||||
|
||||
true
|
||||
end
|
||||
|
@ -479,7 +479,7 @@ class Guardian
|
|||
def can_do?(action, obj)
|
||||
if obj && authenticated?
|
||||
action_method = method_name_for action, obj
|
||||
return (action_method ? send(action_method, obj) : true)
|
||||
return (action_method ? public_send(action_method, obj) : true)
|
||||
else
|
||||
false
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ class Promotion
|
|||
return false if @user.trust_level >= TrustLevel[2]
|
||||
|
||||
review_method = :"review_tl#{@user.trust_level}"
|
||||
return send(review_method) if respond_to?(review_method)
|
||||
return public_send(review_method) if respond_to?(review_method)
|
||||
|
||||
false
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@ class RateLimiter
|
|||
self.after_create do |*args|
|
||||
next if @rate_limits_disabled
|
||||
|
||||
if rate_limiter = send(limiter_method)
|
||||
if rate_limiter = public_send(limiter_method)
|
||||
rate_limiter.performed!
|
||||
@performed ||= {}
|
||||
@performed[limiter_method] = true
|
||||
|
@ -47,14 +47,14 @@ class RateLimiter
|
|||
|
||||
self.after_destroy do
|
||||
next if @rate_limits_disabled
|
||||
if rate_limiter = send(limiter_method)
|
||||
if rate_limiter = public_send(limiter_method)
|
||||
rate_limiter.rollback!
|
||||
end
|
||||
end
|
||||
|
||||
self.after_rollback do
|
||||
next if @rate_limits_disabled
|
||||
if rate_limiter = send(limiter_method)
|
||||
if rate_limiter = public_send(limiter_method)
|
||||
if @performed.present? && @performed[limiter_method]
|
||||
rate_limiter.rollback!
|
||||
@performed[limiter_method] = false
|
||||
|
|
|
@ -612,6 +612,7 @@ class Search
|
|||
def find_grouped_results
|
||||
if @results.type_filter.present?
|
||||
raise Discourse::InvalidAccess.new("invalid type filter") unless Search.facets.include?(@results.type_filter)
|
||||
# calling protected methods
|
||||
send("#{@results.type_filter}_search")
|
||||
else
|
||||
unless @search_context
|
||||
|
|
|
@ -55,9 +55,9 @@ class Search
|
|||
def add(object)
|
||||
type = object.class.to_s.downcase.pluralize
|
||||
|
||||
if @type_filter.present? && send(type).length == Search.per_filter
|
||||
if @type_filter.present? && public_send(type).length == Search.per_filter
|
||||
@more_full_page_results = true
|
||||
elsif !@type_filter.present? && send(type).length == Search.per_facet
|
||||
elsif !@type_filter.present? && public_send(type).length == Search.per_facet
|
||||
instance_variable_set("@more_#{type}".to_sym, true)
|
||||
else
|
||||
(self.public_send(type)) << object
|
||||
|
|
|
@ -64,8 +64,6 @@ class SingleSignOn
|
|||
decoded = Base64.decode64(parsed["sso"])
|
||||
decoded_hash = Rack::Utils.parse_query(decoded)
|
||||
|
||||
return_sso_url = decoded_hash['return_sso_url']
|
||||
|
||||
if sso.sign(parsed["sso"]) != parsed["sig"]
|
||||
diags = "\n\nsso: #{parsed["sso"]}\n\nsig: #{parsed["sig"]}\n\nexpected sig: #{sso.sign(parsed["sso"])}"
|
||||
if parsed["sso"] =~ /[^a-zA-Z0-9=\r\n\/+]/m
|
||||
|
@ -94,7 +92,7 @@ class SingleSignOn
|
|||
end
|
||||
|
||||
def diagnostics
|
||||
SingleSignOn::ACCESSORS.map { |a| "#{a}: #{send(a)}" }.join("\n")
|
||||
SingleSignOn::ACCESSORS.map { |a| "#{a}: #{public_send(a)}" }.join("\n")
|
||||
end
|
||||
|
||||
def sso_secret
|
||||
|
|
|
@ -13,6 +13,7 @@ module SiteSettingExtension
|
|||
# for site locale
|
||||
def self.extended(klass)
|
||||
if GlobalSetting.respond_to?(:default_locale) && GlobalSetting.default_locale.present?
|
||||
# protected
|
||||
klass.send :setup_shadowed_methods, :default_locale, GlobalSetting.default_locale
|
||||
end
|
||||
end
|
||||
|
|
|
@ -219,7 +219,7 @@ class SiteSettings::TypeSupervisor
|
|||
|
||||
validate_method = "validate_#{name}"
|
||||
if self.respond_to? validate_method
|
||||
send(validate_method, val)
|
||||
public_send(validate_method, val)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ class SqlBuilder
|
|||
values.map! do |row|
|
||||
mapped = klass.new
|
||||
setters.each_with_index do |name, index|
|
||||
mapped.send name, row[index]
|
||||
mapped.public_send name, row[index]
|
||||
end
|
||||
mapped
|
||||
end
|
||||
|
|
|
@ -21,6 +21,7 @@ class TopicsBulkAction
|
|||
|
||||
def perform!
|
||||
raise Discourse::InvalidParameters.new(:operation) unless TopicsBulkAction.operations.include?(@operation[:type])
|
||||
# careful these are private methods, we need send
|
||||
send(@operation[:type])
|
||||
@changed_ids
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user