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