A platform for community discussion. Free, open, simple.
DEV: move send => public_send in lib folder
Sam Saffrone2bcf55077be
diff --git a/lib/auth/auth_provider.rb b/lib/auth/auth_provider.rbindex d8705cc0273..853d2fbfb46 100644--- a/lib/auth/auth_provider.rb+++ b/lib/auth/auth_provider.rb@@ -2,7 +2,7 @@ class Auth::AuthProviderinclude ActiveModel::Serializationdef initialize(params = {})- params.each { |key, value| send "#{key}=", value }+ params.each { |key, value| public_send "#{key}=", value }enddef self.auth_attributesdiff --git a/lib/composer_messages_finder.rb b/lib/composer_messages_finder.rbindex 7e296a4d8d5..50d80e9aedd 100644--- a/lib/composer_messages_finder.rb+++ b/lib/composer_messages_finder.rb@@ -14,7 +14,7 @@ class ComposerMessagesFinderreturn if editing_post?self.class.check_methods.each do |m|- msg = send(m)+ msg = public_send(m)return msg if msg.present?enddiff --git a/lib/freedom_patches/inflector_backport.rb b/lib/freedom_patches/inflector_backport.rbindex cc976591557..66c60e52a16 100644--- a/lib/freedom_patches/inflector_backport.rb+++ b/lib/freedom_patches/inflector_backport.rb@@ -25,7 +25,7 @@ module ActiveSupportfound = truedata = 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 corrupteddata.dup@@ -48,7 +48,7 @@ module ActiveSupportdefine_method(method_name) do |*arguments|ActiveSupport::Inflector.clear_memoize!- send(orig, *arguments)+ public_send(orig, *arguments)endendenddiff --git a/lib/guardian.rb b/lib/guardian.rbindex 7bbb3bd44a2..3d62e18b320 100644--- a/lib/guardian.rb+++ b/lib/guardian.rb@@ -118,7 +118,7 @@ class Guardiandef can_see?(obj)if objsee_method = method_name_for :see, obj- return (see_method ? send(see_method, obj) : true)+ return (see_method ? public_send(see_method, obj) : true)endend@@ -137,7 +137,7 @@ class Guardianendcreate_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)trueend@@ -479,7 +479,7 @@ class Guardiandef 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)elsefalseenddiff --git a/lib/promotion.rb b/lib/promotion.rbindex c10f2bbf855..8e070b58ca6 100644--- a/lib/promotion.rb+++ b/lib/promotion.rb@@ -17,7 +17,7 @@ class Promotionreturn 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)falseenddiff --git a/lib/rate_limiter/on_create_record.rb b/lib/rate_limiter/on_create_record.rbindex 3a8483cd8e1..c4689adb1a8 100644--- a/lib/rate_limiter/on_create_record.rb+++ b/lib/rate_limiter/on_create_record.rb@@ -38,7 +38,7 @@ class RateLimiterself.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 RateLimiterself.after_destroy donext if @rate_limits_disabled- if rate_limiter = send(limiter_method)+ if rate_limiter = public_send(limiter_method)rate_limiter.rollback!endendself.after_rollback donext 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] = falsediff --git a/lib/search.rb b/lib/search.rbindex fbc1e8c12ed..db25ecd4864 100644--- a/lib/search.rb+++ b/lib/search.rb@@ -612,6 +612,7 @@ class Searchdef find_grouped_resultsif @results.type_filter.present?raise Discourse::InvalidAccess.new("invalid type filter") unless Search.facets.include?(@results.type_filter)+ # calling protected methodssend("#{@results.type_filter}_search")elseunless @search_contextdiff --git a/lib/search/grouped_search_results.rb b/lib/search/grouped_search_results.rbindex 1f32eaad0a3..055682afc82 100644--- a/lib/search/grouped_search_results.rb+++ b/lib/search/grouped_search_results.rb@@ -55,9 +55,9 @@ class Searchdef 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_facetinstance_variable_set("@more_#{type}".to_sym, true)else(self.public_send(type)) << objectdiff --git a/lib/single_sign_on.rb b/lib/single_sign_on.rbindex fd5b83e83bb..359006c4910 100644--- a/lib/single_sign_on.rb+++ b/lib/single_sign_on.rb@@ -64,8 +64,6 @@ class SingleSignOndecoded = 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 SingleSignOnenddef diagnostics- SingleSignOn::ACCESSORS.map { |a| "#{a}: #{send(a)}" }.join("\n")+ SingleSignOn::ACCESSORS.map { |a| "#{a}: #{public_send(a)}" }.join("\n")enddef sso_secretdiff --git a/lib/site_setting_extension.rb b/lib/site_setting_extension.rbindex 80332cc891d..59dc8b739c4 100644--- a/lib/site_setting_extension.rb+++ b/lib/site_setting_extension.rb@@ -13,6 +13,7 @@ module SiteSettingExtension# for site localedef self.extended(klass)if GlobalSetting.respond_to?(:default_locale) && GlobalSetting.default_locale.present?+ # protectedklass.send :setup_shadowed_methods, :default_locale, GlobalSetting.default_localeendenddiff --git a/lib/site_settings/type_supervisor.rb b/lib/site_settings/type_supervisor.rbindex da210d82109..29fda7075ef 100644--- a/lib/site_settings/type_supervisor.rb+++ b/lib/site_settings/type_supervisor.rb@@ -219,7 +219,7 @@ class SiteSettings::TypeSupervisorvalidate_method = "validate_#{name}"if self.respond_to? validate_method- send(validate_method, val)+ public_send(validate_method, val)endenddiff --git a/lib/sql_builder.rb b/lib/sql_builder.rbindex d43da3dffc8..fdf0a8582e4 100644--- a/lib/sql_builder.rb+++ b/lib/sql_builder.rb@@ -110,7 +110,7 @@ class SqlBuildervalues.map! do |row|mapped = klass.newsetters.each_with_index do |name, index|- mapped.send name, row[index]+ mapped.public_send name, row[index]endmappedenddiff --git a/lib/topics_bulk_action.rb b/lib/topics_bulk_action.rbindex 4b2618710d5..0db1bb154bb 100644--- a/lib/topics_bulk_action.rb+++ b/lib/topics_bulk_action.rb@@ -21,6 +21,7 @@ class TopicsBulkActiondef perform!raise Discourse::InvalidParameters.new(:operation) unless TopicsBulkAction.operations.include?(@operation[:type])+ # careful these are private methods, we need sendsend(@operation[:type])@changed_idsend