Skip to content

A platform for community discussion. Free, open, simple.

DEV: Prefer `public_send` over `send`.

Guo Xiang Tan152238b4cff7
diff --git a/app/controllers/admin/badges_controller.rb b/app/controllers/admin/badges_controller.rb
index 90da2ffaf1e..0a1b741fd45 100644
--- a/app/controllers/admin/badges_controller.rb
+++ b/app/controllers/admin/badges_controller.rb
@@ -108,7 +108,7 @@ class Admin::BadgesController < Admin::AdminController
params.permit(*allowed)
allowed.each do |key|
- badge.send("#{key}=" , params[key]) if params[key]
+ badge.public_send("#{key}=" , params[key]) if params[key]
end
# Badge query contract checks
diff --git a/app/controllers/admin/email_controller.rb b/app/controllers/admin/email_controller.rb
index a668f71eea8..e8c81111fa0 100644
--- a/app/controllers/admin/email_controller.rb
+++ b/app/controllers/admin/email_controller.rb
@@ -113,7 +113,11 @@ class Admin::EmailController < Admin::AdminController
params.require(:username)
params.require(:email)
user = User.find_by_username(params[:username])
- message, skip_reason = UserNotifications.send(:digest, user, since: params[:last_seen_at])
+
+ message, skip_reason = UserNotifications.public_send(:digest, user,
+ since: params[:last_seen_at]
+ )
+
if message
message.to = params[:email]
begin
diff --git a/app/controllers/admin/embedding_controller.rb b/app/controllers/admin/embedding_controller.rb
index d1b645e17ed..e2559fb85a5 100644
--- a/app/controllers/admin/embedding_controller.rb
+++ b/app/controllers/admin/embedding_controller.rb
@@ -16,7 +16,7 @@ class Admin::EmbeddingController < Admin::AdminController
end
Embedding.settings.each do |s|
- @embedding.send("#{s}=", params[:embedding][s])
+ @embedding.public_send("#{s}=", params[:embedding][s])
end
if @embedding.save
diff --git a/app/controllers/admin/themes_controller.rb b/app/controllers/admin/themes_controller.rb
index 9e4d78df05a..042f5bcf2c3 100644
--- a/app/controllers/admin/themes_controller.rb
+++ b/app/controllers/admin/themes_controller.rb
@@ -157,7 +157,7 @@ class Admin::ThemesController < Admin::AdminController
[:name, :color_scheme_id, :user_selectable].each do |field|
if theme_params.key?(field)
- @theme.send("#{field}=", theme_params[field])
+ @theme.public_send("#{field}=", theme_params[field])
end
end
diff --git a/app/controllers/admin/user_fields_controller.rb b/app/controllers/admin/user_fields_controller.rb
index 4ac32bb9118..1139560a6b9 100644
--- a/app/controllers/admin/user_fields_controller.rb
+++ b/app/controllers/admin/user_fields_controller.rb
@@ -27,7 +27,7 @@ class Admin::UserFieldsController < Admin::AdminController
Admin::UserFieldsController.columns.each do |col|
unless field_params[col].nil?
- field.send("#{col}=", field_params[col])
+ field.public_send("#{col}=", field_params[col])
end
end
update_options(field)
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index 0bdc7bbbafd..4b77c5d0759 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -254,7 +254,7 @@ class Admin::UsersController < Admin::AdminController
level = params[:level].to_i
if @user.manual_locked_trust_level.nil?
- if [0, 1, 2].include?(level) && Promotion.send("tl#{level + 1}_met?", @user)
+ if [0, 1, 2].include?(level) && Promotion.public_send("tl#{level + 1}_met?", @user)
@user.manual_locked_trust_level = level
@user.save
elsif level == 3 && Promotion.tl3_lost?(@user)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index ddce4935d7b..152bebae7dd 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -628,10 +628,10 @@ class ApplicationController < ActionController::Base
error_obj = nil
if opts[:additional_errors]
error_target = opts[:additional_errors].find do |o|
- target = obj.send(o)
+ target = obj.public_send(o)
target && target.errors.present?
end
- error_obj = obj.send(error_target) if error_target
+ error_obj = obj.public_send(error_target) if error_target
end
render_json_error(error_obj || obj)
end
diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb
index 7723b7fe5e1..b4f80364636 100644
--- a/app/controllers/categories_controller.rb
+++ b/app/controllers/categories_controller.rb
@@ -240,9 +240,9 @@ class CategoriesController < ApplicationController
draft = Draft.get(current_user, draft_key, draft_sequence) if current_user
%w{category topic}.each do |type|
- result.send(:"#{type}_list").draft = draft
- result.send(:"#{type}_list").draft_key = draft_key
- result.send(:"#{type}_list").draft_sequence = draft_sequence
+ result.public_send(:"#{type}_list").draft = draft
+ result.public_send(:"#{type}_list").draft_key = draft_key
+ result.public_send(:"#{type}_list").draft_sequence = draft_sequence
end
render_serialized(result, CategoryAndTopicListsSerializer, root: false)
diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rb
index fa2c4a0f1bc..f7bed67a39d 100644
--- a/app/controllers/list_controller.rb
+++ b/app/controllers/list_controller.rb
@@ -117,20 +117,20 @@ class ListController < ApplicationController
define_method("category_#{filter}") do
canonical_url "#{Discourse.base_url_no_prefix}#{@category.url}"
- self.send(filter, category: @category.id)
+ self.public_send(filter, category: @category.id)
end
define_method("category_none_#{filter}") do
- self.send(filter, category: @category.id, no_subcategories: true)
+ self.public_send(filter, category: @category.id, no_subcategories: true)
end
define_method("parent_category_category_#{filter}") do
canonical_url "#{Discourse.base_url_no_prefix}#{@category.url}"
- self.send(filter, category: @category.id)
+ self.public_send(filter, category: @category.id)
end
define_method("parent_category_category_none_#{filter}") do
- self.send(filter, category: @category.id)
+ self.public_send(filter, category: @category.id)
end
end
@@ -142,7 +142,7 @@ class ListController < ApplicationController
if view_method == 'top'
top(category: @category.id)
else
- self.send(view_method)
+ self.public_send(view_method)
end
end
@@ -237,7 +237,10 @@ class ListController < ApplicationController
@link = "#{Discourse.base_url}/u/#{target_user.username}/activity/topics"
@atom_link = "#{Discourse.base_url}/u/#{target_user.username}/activity/topics.rss"
@description = I18n.t("rss_description.user_topics", username: target_user.username)
- @topic_list = TopicQuery.new(nil, order: 'created').send("list_topics_by", target_user)
+
+ @topic_list = TopicQuery
+ .new(nil, order: 'created')
+ .public_send("list_topics_by", target_user)
render 'list', formats: [:rss]
end
@@ -285,15 +288,18 @@ class ListController < ApplicationController
end
define_method("category_top_#{period}") do
- self.send("top_#{period}", category: @category.id)
+ self.public_send("top_#{period}", category: @category.id)
end
define_method("category_none_top_#{period}") do
- self.send("top_#{period}", category: @category.id, no_subcategories: true)
+ self.public_send("top_#{period}",
+ category: @category.id,
+ no_subcategories: true
+ )
end
define_method("parent_category_category_top_#{period}") do
- self.send("top_#{period}", category: @category.id)
+ self.public_send("top_#{period}", category: @category.id)
end
# rss feed
@@ -398,7 +404,7 @@ class ListController < ApplicationController
end
def generate_list_for(action, target_user, opts)
- TopicQuery.new(current_user, opts).send("list_#{action}", target_user)
+ TopicQuery.new(current_user, opts).public_send("list_#{action}", target_user)
end
def construct_url_with(action, opts, url_prefix = nil)
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index 20126f195e1..739580e682c 100644
--- a/app/controllers/posts_controller.rb
+++ b/app/controllers/posts_controller.rb
@@ -200,7 +200,10 @@ class PostsController < ApplicationController
post.image_sizes = params[:image_sizes] if params[:image_sizes].present?
- if !guardian.send("can_edit?", post) && post.user_id == current_user.id && post.edit_time_limit_expired?
+ if !guardian.public_send("can_edit?", post) &&
+ post.user_id == current_user.id &&
+ post.edit_time_limit_expired?
+
return render_json_error(I18n.t('too_late_to_edit'))
end
diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb
index d20cd7de49e..0276e6f72a6 100644
--- a/app/controllers/static_controller.rb
+++ b/app/controllers/static_controller.rb
@@ -38,7 +38,7 @@ class StaticController < ApplicationController
@page.gsub!(/[^a-z0-9\_\-]/, '')
if map.has_key?(@page)
- @topic = Topic.find_by_id(SiteSetting.send(map[@page][:topic_id]))
+ @topic = Topic.find_by_id(SiteSetting.get(map[@page][:topic_id]))
raise Discourse::NotFound unless @topic
title_prefix = if I18n.exists?("js.#{@page}")
I18n.t("js.#{@page}")
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index adcb3b9d517..1b60096e398 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1036,7 +1036,7 @@ class UsersController < ApplicationController
result = {}
%W{number_of_deleted_posts number_of_flagged_posts number_of_flags_given number_of_suspensions warnings_received_count}.each do |info|
- result[info] = @user.send(info)
+ result[info] = @user.public_send(info)
end
render json: result
diff --git a/app/jobs/regular/enable_bootstrap_mode.rb b/app/jobs/regular/enable_bootstrap_mode.rb
index 1bbc2cf0495..34cc5e7165e 100644
--- a/app/jobs/regular/enable_bootstrap_mode.rb
+++ b/app/jobs/regular/enable_bootstrap_mode.rb
@@ -10,8 +10,14 @@ module Jobs
return unless user.is_singular_admin?
# let's enable bootstrap mode settings
- SiteSetting.set_and_log('default_trust_level', TrustLevel[1]) if SiteSetting.get('default_trust_level') == TrustLevel[0]
- SiteSetting.set_and_log('default_email_digest_frequency', 1440) if SiteSetting.get('default_email_digest_frequency') == 10080
+ if SiteSetting.default_trust_level == TrustLevel[0]
+ SiteSetting.set_and_log('default_trust_level', TrustLevel[1])
+ end
+
+ if SiteSetting.default_email_digest_frequency == 10080
+ SiteSetting.set_and_log('default_email_digest_frequency', 1440)
+ end
+
SiteSetting.set_and_log('bootstrap_mode_enabled', true)
end
end
diff --git a/app/jobs/regular/user_email.rb b/app/jobs/regular/user_email.rb
index 7e7d8f58090..36eae216070 100644
--- a/app/jobs/regular/user_email.rb
+++ b/app/jobs/regular/user_email.rb
@@ -170,7 +170,7 @@ module Jobs
end
message = EmailLog.unique_email_per_post(post, user) do
- UserNotifications.send(type, user, email_args)
+ UserNotifications.public_send(type, user, email_args)
end
# Update the to address if we have a custom one
diff --git a/app/jobs/scheduled/disable_bootstrap_mode.rb b/app/jobs/scheduled/disable_bootstrap_mode.rb
index cf84708c44e..139e5721712 100644
--- a/app/jobs/scheduled/disable_bootstrap_mode.rb
+++ b/app/jobs/scheduled/disable_bootstrap_mode.rb
@@ -7,8 +7,14 @@ module Jobs
total_users = User.human_users.count
if SiteSetting.bootstrap_mode_min_users == 0 || total_users > SiteSetting.bootstrap_mode_min_users
- SiteSetting.set_and_log('default_trust_level', TrustLevel[0]) if SiteSetting.get('default_trust_level') == TrustLevel[1]
- SiteSetting.set_and_log('default_email_digest_frequency', 10080) if SiteSetting.get('default_email_digest_frequency') == 1440
+ if SiteSetting.default_trust_level == TrustLevel[1]
+ SiteSetting.set_and_log('default_trust_level', TrustLevel[0])
+ end
+
+ if SiteSetting.default_email_digest_frequency == 1440
+ SiteSetting.set_and_log('default_email_digest_frequency', 10080)
+ end
+
SiteSetting.set_and_log('bootstrap_mode_enabled', false)
end
end
diff --git a/app/models/concerns/roleable.rb b/app/models/concerns/roleable.rb
index 554ba1c35ea..51c50dc49c7 100644
--- a/app/models/concerns/roleable.rb
+++ b/app/models/concerns/roleable.rb
@@ -40,7 +40,7 @@ module Roleable
end
def set_permission(permission_name, value)
- self.send("#{permission_name}=", value)
+ self.public_send("#{permission_name}=", value)
save_and_refresh_staff_groups!
end
diff --git a/app/models/embedding.rb b/app/models/embedding.rb
index 3e9b1a38ddf..5216a47864f 100644
--- a/app/models/embedding.rb
+++ b/app/models/embedding.rb
@@ -38,7 +38,10 @@ class Embedding < OpenStruct
def self.find
embedding_args = { id: 'default' }
- Embedding.settings.each { |s| embedding_args[s] = SiteSetting.send(s) }
+ Embedding.settings.each do |s|
+ embedding_args[s] = SiteSetting.public_send(s)
+ end
+
Embedding.new(embedding_args)
end
end
diff --git a/app/models/global_setting.rb b/app/models/global_setting.rb
index 56abedade9a..a630b135785 100644
--- a/app/models/global_setting.rb
+++ b/app/models/global_setting.rb
@@ -111,7 +111,7 @@ class GlobalSetting
replica_host
replica_port
}.each do |s|
- if val = self.send("db_#{s}")
+ if val = self.public_send("db_#{s}")
hash[s] = val
end
end
diff --git a/app/models/optimized_image.rb b/app/models/optimized_image.rb
index 9dc037e660b..768c7325d0a 100644
--- a/app/models/optimized_image.rb
+++ b/app/models/optimized_image.rb
@@ -321,10 +321,12 @@ class OptimizedImage < ActiveRecord::Base
def self.optimize(operation, from, to, dimensions, opts = {})
method_name = "#{operation}_instructions"
+
if !!opts[:allow_animation] && (from =~ /\.GIF$/i)
method_name += "_animated"
end
- instructions = self.send(method_name.to_sym, from, to, dimensions, opts)
+
+ instructions = self.public_send(method_name.to_sym, from, to, dimensions, opts)
convert_with(instructions, to, opts)
end
diff --git a/app/models/post.rb b/app/models/post.rb
index 8b98d039f72..65187aed0fa 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -257,7 +257,7 @@ class Post < ActiveRecord::Base
raw_links
has_oneboxes?}.each do |attr|
define_method(attr) do
- post_analyzer.send(attr)
+ post_analyzer.public_send(attr)
end
end
diff --git a/app/models/report.rb b/app/models/report.rb
index 0fb79f2f3e2..d3e2a9f7fcf 100644
--- a/app/models/report.rb
+++ b/app/models/report.rb
@@ -240,14 +240,14 @@ class Report
def self.basic_report_about(report, subject_class, report_method, *args)
report.data = []
- subject_class.send(report_method, *args).each do |date, count|
+ subject_class.public_send(report_method, *args).each do |date, count|
report.data << { x: date, y: count }
end
end
def self.add_prev_data(report, subject_class, report_method, *args)
if report.modes.include?(:chart) && report.facets.include?(:prev_period)
- prev_data = subject_class.send(report_method, *args)
+ prev_data = subject_class.public_send(report_method, *args)
report.prev_data = prev_data.map { |k, v| { x: k, y: v } }
end
end
diff --git a/app/models/top_topic.rb b/app/models/top_topic.rb
index 58703023b46..00362226285 100644
--- a/app/models/top_topic.rb
+++ b/app/models/top_topic.rb
@@ -53,7 +53,7 @@ class TopTopic < ActiveRecord::Base
def self.update_counts_and_compute_scores_for(period)
sort_orders.each do |sort|
- TopTopic.send("update_#{sort}_count_for", period)
+ TopTopic.public_send("update_#{sort}_count_for", period)
end
compute_top_score_for(period)
end
diff --git a/app/models/user.rb b/app/models/user.rb
index cde8851a4a9..6e155dde28b 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -351,7 +351,7 @@ class User < ActiveRecord::Base
def self.unstage(params)
if user = User.where(staged: true).with_email(params[:email].strip.downcase).first
- params.each { |k, v| user.send("#{k}=", v) }
+ params.each { |k, v| user.public_send("#{k}=", v) }
user.active = false
user.unstage
end
diff --git a/app/models/username_validator.rb b/app/models/username_validator.rb
index 465d3a1b6ac..3e6ea7c423a 100644
--- a/app/models/username_validator.rb
+++ b/app/models/username_validator.rb
@@ -9,7 +9,7 @@ class UsernameValidator
#
# Example: UsernameValidator.perform_validation(user, 'name')
def self.perform_validation(object, field_name)
- validator = UsernameValidator.new(object.send(field_name))
+ validator = UsernameValidator.new(object.public_send(field_name))
unless validator.valid_format?
validator.errors.each { |e| object.errors.add(field_name.to_sym, e) }
end
diff --git a/app/serializers/admin_user_list_serializer.rb b/app/serializers/admin_user_list_serializer.rb
index 6c09e638555..d9156edcaa1 100644
--- a/app/serializers/admin_user_list_serializer.rb
+++ b/app/serializers/admin_user_list_serializer.rb
@@ -31,7 +31,7 @@ class AdminUserListSerializer < BasicUserSerializer
[:days_visited, :posts_read_count, :topics_entered, :post_count].each do |sym|
attributes sym
define_method sym do
- object.user_stat.send(sym)
+ object.user_stat.public_send(sym)
end
end
diff --git a/app/serializers/category_detailed_serializer.rb b/app/serializers/category_detailed_serializer.rb
index 9e3ab0dcb68..60187e4cd3e 100644
--- a/app/serializers/category_detailed_serializer.rb
+++ b/app/serializers/category_detailed_serializer.rb
@@ -54,10 +54,12 @@ class CategoryDetailedSerializer < BasicCategorySerializer
end
def count_with_subcategories(method)
- count = object.send(method) || 0
+ count = object.public_send(method) || 0
+
object.subcategories.each do |category|
- count += (category.send(method) || 0)
+ count += (category.public_send(method) || 0)
end
+
count
end
diff --git a/app/serializers/embeddable_host_serializer.rb b/app/serializers/embeddable_host_serializer.rb
index e99ce6d4b67..1d51c9fc8b2 100644
--- a/app/serializers/embeddable_host_serializer.rb
+++ b/app/serializers/embeddable_host_serializer.rb
@@ -5,7 +5,7 @@ class EmbeddableHostSerializer < ApplicationSerializer
attributes *TO_SERIALIZE
TO_SERIALIZE.each do |attr|
- define_method(attr) { object.send(attr) }
+ define_method(attr) { object.public_send(attr) }
end
end
diff --git a/app/serializers/embedding_serializer.rb b/app/serializers/embedding_serializer.rb
index dda224edc00..9ab41895359 100644
--- a/app/serializers/embedding_serializer.rb
+++ b/app/serializers/embedding_serializer.rb
@@ -9,6 +9,6 @@ class EmbeddingSerializer < ApplicationSerializer
end
def read_attribute_for_serialization(attr)
- object.respond_to?(attr) ? object.send(attr) : send(attr)
+ object.respond_to?(attr) ? object.public_send(attr) : public_send(attr)
end
end
diff --git a/app/serializers/post_revision_serializer.rb b/app/serializers/post_revision_serializer.rb
index 6bfb7dbb033..4278f52dad4 100644
--- a/app/serializers/post_revision_serializer.rb
+++ b/app/serializers/post_revision_serializer.rb
@@ -201,7 +201,9 @@ class PostRevisionSerializer < ApplicationSerializer
# Retrieve any `tracked_topic_fields`
PostRevisor.tracked_topic_fields.each_key do |field|
- latest_modifications[field.to_s] = [topic.send(field)] if topic.respond_to?(field)
+ if topic.respond_to?(field)
+ latest_modifications[field.to_s] = [topic.public_send(field)]
+ end
end
latest_modifications["featured_link"] = [post.topic.featured_link] if SiteSetting.topic_featured_link_enabled
diff --git a/app/serializers/post_serializer.rb b/app/serializers/post_serializer.rb
index 9ec373fbf3c..ca229d78326 100644
--- a/app/serializers/post_serializer.rb
+++ b/app/serializers/post_serializer.rb
@@ -14,7 +14,7 @@ class PostSerializer < BasicPostSerializer
]
INSTANCE_VARS.each do |v|
- self.send(:attr_accessor, v)
+ self.public_send(:attr_accessor, v)
end
attributes :post_number,
@@ -80,9 +80,10 @@ class PostSerializer < BasicPostSerializer
def initialize(object, opts)
super(object, opts)
+
PostSerializer::INSTANCE_VARS.each do |name|
if opts.include? name
- self.send("#{name}=", opts[name])
+ self.public_send("#{name}=", opts[name])
end
end
end
@@ -242,7 +243,7 @@ class PostSerializer < BasicPostSerializer
PostActionType.types.except(:bookmark).each do |sym, id|
count_col = "#{sym}_count".to_sym
- count = object.send(count_col) if object.respond_to?(count_col)
+ count = object.public_send(count_col) if object.respond_to?(count_col)
summary = { id: id, count: count }
summary[:hidden] = true if sym == :vote
diff --git a/app/serializers/top_list_serializer.rb b/app/serializers/top_list_serializer.rb
index 8712a8796f7..93c4137079d 100644
--- a/app/serializers/top_list_serializer.rb
+++ b/app/serializers/top_list_serializer.rb
@@ -13,7 +13,9 @@ class TopListSerializer < ApplicationSerializer
attribute period
define_method(period) do
- TopicListSerializer.new(object.send(period), scope: scope).as_json if object.send(period)
+ if object.public_send(period)
+ TopicListSerializer.new(object.public_send(period), scope: scope).as_json
+ end
end
end
diff --git a/app/services/notification_emailer.rb b/app/services/notification_emailer.rb
index 7d10072af08..ab2421d4b97 100644
--- a/app/services/notification_emailer.rb
+++ b/app/services/notification_emailer.rb
@@ -126,7 +126,7 @@ class NotificationEmailer
email_user = EmailUser.new(notification)
email_method = Notification.types[notification.notification_type]
- email_user.send(email_method) if email_user.respond_to? email_method
+ email_user.public_send(email_method) if email_user.respond_to? email_method
end
end
diff --git a/app/services/staff_action_logger.rb b/app/services/staff_action_logger.rb
index dae6589cd3b..1f33fca2224 100644
--- a/app/services/staff_action_logger.rb
+++ b/app/services/staff_action_logger.rb
@@ -16,7 +16,11 @@ class StaffActionLogger
def log_user_deletion(deleted_user, opts = {})
raise Discourse::InvalidParameters.new(:deleted_user) unless deleted_user && deleted_user.is_a?(User)
- details = USER_FIELDS.map { |x| "#{x}: #{deleted_user.send(x)}" }.join("\n")
+
+ details = USER_FIELDS.map do |x|
+ "#{x}: #{deleted_user.public_send(x)}"
+ end.join("\n")
+
UserHistory.create!(params(opts).merge(
action: UserHistory.actions[:delete_user],
ip_address: deleted_user.ip_address.to_s,
@@ -268,7 +272,11 @@ class StaffActionLogger
def log_badge_creation(badge)
raise Discourse::InvalidParameters.new(:badge) unless badge
- details = BADGE_FIELDS.map { |f| [f, badge.send(f)] }.select { |f, v| v.present? }.map { |f, v| "#{f}: #{v}" }
+
+ details = BADGE_FIELDS.map do |f|
+ [f, badge.public_send(f)]
+ end.select { |f, v| v.present? }.map { |f, v| "#{f}: #{v}" }
+
UserHistory.create!(params.merge(
action: UserHistory.actions[:create_badge],
details: details.join("\n")
@@ -287,7 +295,11 @@ class StaffActionLogger
def log_badge_deletion(badge)
raise Discourse::InvalidParameters.new(:badge) unless badge
- details = BADGE_FIELDS.map { |f| [f, badge.send(f)] }.select { |f, v| v.present? }.map { |f, v| "#{f}: #{v}" }
+
+ details = BADGE_FIELDS.map do |f|
+ [f, badge.public_send(f)]
+ end.select { |f, v| v.present? }.map { |f, v| "#{f}: #{v}" }
+
UserHistory.create!(params.merge(
action: UserHistory.actions[:delete_badge],
details: details.join("\n")
diff --git a/app/services/topic_status_updater.rb b/app/services/topic_status_updater.rb
index cd1ea0d94f7..09c6f2e8956 100644
--- a/app/services/topic_status_updater.rb
+++ b/app/services/topic_status_updater.rb
@@ -32,7 +32,7 @@ TopicStatusUpdater = Struct.new(:topic, :user) do
rc = Topic.where(:id => topic.id, status.name => !status.enabled)
.update_all(status.name => status.enabled?)
- topic.send("#{status.name}=", status.enabled?)
+ topic.public_send("#{status.name}=", status.enabled?)
result = false if rc == 0
end
diff --git a/app/services/user_updater.rb b/app/services/user_updater.rb
index 7803856ed62..bffeb66afda 100644
--- a/app/services/user_updater.rb
+++ b/app/services/user_updater.rb
@@ -113,11 +113,11 @@ class UserUpdater
if attributes.key?(attribute)
save_options = true
- if [true, false].include?(user.user_option.send(attribute))
+ if [true, false].include?(user.user_option.public_send(attribute))
val = attributes[attribute].to_s == 'true'
- user.user_option.send("#{attribute}=", val)
+ user.user_option.public_send("#{attribute}=", val)
else
- user.user_option.send("#{attribute}=", attributes[attribute])
+ user.user_option.public_send("#{attribute}=", attributes[attribute])
end
end
end
diff --git a/config/initializers/100-strong_parameters.rb b/config/initializers/100-strong_parameters.rb
index 394c1f5fd42..ddc8cf3b6be 100644
--- a/config/initializers/100-strong_parameters.rb
+++ b/config/initializers/100-strong_parameters.rb
@@ -1 +1 @@
-ActiveRecord::Base.send(:include, ActiveModel::ForbiddenAttributesProtection)
+ActiveRecord::Base.public_send(:include, ActiveModel::ForbiddenAttributesProtection)
diff --git a/db/fixtures/001_refresh.rb b/db/fixtures/001_refresh.rb
index c206aee9083..5969a2e2a89 100644
--- a/db/fixtures/001_refresh.rb
+++ b/db/fixtures/001_refresh.rb
@@ -1,3 +1,3 @@
# fix any bust caches post initial migration
-ActiveRecord::Base.send(:subclasses).each { |m| m.reset_column_information }
+ActiveRecord::Base.public_send(:subclasses).each { |m| m.reset_column_information }
SiteSetting.refresh!
diff --git a/lib/custom_renderer.rb b/lib/custom_renderer.rb
index ab10ca7eeb3..e8451f27e19 100644
--- a/lib/custom_renderer.rb
+++ b/lib/custom_renderer.rb
@@ -18,11 +18,11 @@ class CustomRenderer < AbstractController::Base
end
def cookies
- @parent.send(:cookies)
+ @parent.public_send(:cookies)
end
def session
- @parent.send(:session)
+ @parent.public_send(:session)
end
def initialize(parent)
diff --git a/lib/db_helper.rb b/lib/db_helper.rb
index e99765263a3..fced634ab6d 100644
--- a/lib/db_helper.rb
+++ b/lib/db_helper.rb
@@ -95,7 +95,9 @@ class DbHelper
SQL
if rows.size > 0
- found["#{r.table_name}.#{r.column_name}"] = rows.map { |row| row.send(r.column_name) }
+ found["#{r.table_name}.#{r.column_name}"] = rows.map do |row|
+ row.public_send(r.column_name)
+ end
end
end
diff --git a/lib/discourse_hub.rb b/lib/discourse_hub.rb
index a4b9db04006..6e3ea6cae30 100644
--- a/lib/discourse_hub.rb
+++ b/lib/discourse_hub.rb
@@ -40,7 +40,8 @@ module DiscourseHub
def self.singular_action(action, rel_url, params = {})
connect_opts = connect_opts(params)
- JSON.parse(Excon.send(action,
+
+ JSON.parse(Excon.public_send(action,
"#{hub_base_url}#{rel_url}",
{
headers: { 'Referer' => referer, 'Accept' => accepts.join(', ') },
@@ -53,7 +54,7 @@ module DiscourseHub
def self.collection_action(action, rel_url, params = {})
connect_opts = connect_opts(params)
- response = Excon.send(action,
+ response = Excon.public_send(action,
"#{hub_base_url}#{rel_url}",
{
body: JSON[params],
diff --git a/lib/discourse_plugin.rb b/lib/discourse_plugin.rb
index a2f86705aec..b2488af93c4 100644
--- a/lib/discourse_plugin.rb
+++ b/lib/discourse_plugin.rb
@@ -20,7 +20,7 @@ class DiscoursePlugin
original_class = mixin.to_s.demodulize.sub("Mixin", "")
dependency_file_name = original_class.underscore
require_dependency(dependency_file_name)
- original_class.constantize.send(:include, mixin)
+ original_class.constantize.public_send(:include, mixin)
end
end
diff --git a/lib/discourse_redis.rb b/lib/discourse_redis.rb
index 17954eb798b..f0e8df2dc1a 100644
--- a/lib/discourse_redis.rb
+++ b/lib/discourse_redis.rb
@@ -184,7 +184,7 @@ class DiscourseRedis
# prefix the key with the namespace
def method_missing(meth, *args, &block)
if @redis.respond_to?(meth)
- DiscourseRedis.ignore_readonly { @redis.send(meth, *args, &block) }
+ DiscourseRedis.ignore_readonly { @redis.public_send(meth, *args, &block) }
else
super
end
@@ -201,7 +201,7 @@ class DiscourseRedis
:zremrangebyscore, :zrevrange, :zrevrangebyscore, :zrevrank, :zrangebyscore ].each do |m|
define_method m do |*args|
args[0] = "#{namespace}:#{args[0]}" if @namespace
- DiscourseRedis.ignore_readonly { @redis.send(m, *args) }
+ DiscourseRedis.ignore_readonly { @redis.public_send(m, *args) }
end
end
diff --git a/lib/email/message_builder.rb b/lib/email/message_builder.rb
index 55b64cd5246..d57665a23be 100644
--- a/lib/email/message_builder.rb
+++ b/lib/email/message_builder.rb
@@ -107,8 +107,9 @@ module Email
styled = Email::Styles.new(html_override, @opts)
styled.format_basic
+
if style = @opts[:style]
- styled.send("format_#{style}")
+ styled.public_send("format_#{style}")
end
Mail::Part.new do
diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb
index 2f5bc9c806b..9af3d157322 100644
--- a/lib/email/receiver.rb
+++ b/lib/email/receiver.rb
@@ -345,7 +345,7 @@ module Email
# use the first html extracter that matches
if html_extracter = HTML_EXTRACTERS.select { |_, r| html[r] }.min_by { |_, r| html =~ r }
doc = Nokogiri::HTML.fragment(html)
- self.send(:"extract_from_#{html_extracter[0]}", doc)
+ self.public_send(:"extract_from_#{html_extracter[0]}", doc)
else
markdown = HtmlToMarkdown.new(html, keep_img_tags: true, keep_cid_imgs: true).to_markdown
markdown = trim_discourse_markers(markdown)
@@ -1176,7 +1176,7 @@ module Email
end
def send_subscription_mail(action, user)
- message = SubscriptionMailer.send(action, user)
+ message = SubscriptionMailer.public_send(action, user)
Email::Sender.new(message, :subscription).send
end
diff --git a/lib/feed_item_accessor.rb b/lib/feed_item_accessor.rb
index 36acabcbf5c..af8908d02ce 100644
--- a/lib/feed_item_accessor.rb
+++ b/lib/feed_item_accessor.rb
@@ -16,10 +16,10 @@ class FeedItemAccessor
private
def element(element_name)
- rss_item.respond_to?(element_name) ? rss_item.send(element_name) : nil
+ rss_item.respond_to?(element_name) ? rss_item.public_send(element_name) : nil
end
def try_attribute_or_self(element, attribute_name)
- element.respond_to?(attribute_name) ? element.send(attribute_name) : element
+ element.respond_to?(attribute_name) ? element.public_send(attribute_name) : element
end
end
diff --git a/lib/freedom_patches/active_record_base.rb b/lib/freedom_patches/active_record_base.rb
index 39687ce2aa3..e21eefe4bd9 100644
--- a/lib/freedom_patches/active_record_base.rb
+++ b/lib/freedom_patches/active_record_base.rb
@@ -27,7 +27,7 @@ class ActiveRecord::Base
Discourse.deprecate("exec_sql should not be used anymore, please use DB.exec or DB.query instead!")
conn = ActiveRecord::Base.connection
- sql = ActiveRecord::Base.send(:sanitize_sql_array, args)
+ sql = ActiveRecord::Base.public_send(:sanitize_sql_array, args)
conn.raw_connection.async_exec(sql)
end
diff --git a/lib/freedom_patches/schema_migration_details.rb b/lib/freedom_patches/schema_migration_details.rb
index 2c2722fdc77..790676c8ec6 100644
--- a/lib/freedom_patches/schema_migration_details.rb
+++ b/lib/freedom_patches/schema_migration_details.rb
@@ -30,7 +30,7 @@ module FreedomPatches
SQL
hostname = `hostname` rescue ""
- sql = ActiveRecord::Base.send(:sanitize_sql_array, [sql, {
+ sql = ActiveRecord::Base.public_send(:sanitize_sql_array, [sql, {
version: version || "",
duration: (time.real * 1000).to_i,
hostname: hostname,
diff --git a/lib/import_export/base_exporter.rb b/lib/import_export/base_exporter.rb
index 77057406ce3..ec47246033e 100644
--- a/lib/import_export/base_exporter.rb
+++ b/lib/import_export/base_exporter.rb
@@ -26,7 +26,7 @@ module ImportExport
data = []
categories.each do |cat|
- data << CATEGORY_ATTRS.inject({}) { |h, a| h[a] = cat.send(a); h }
+ data << CATEGORY_ATTRS.inject({}) { |h, a| h[a] = cat.public_send(a); h }
end
data
@@ -53,7 +53,7 @@ module ImportExport
return [] if group_names.empty?
Group.where(name: group_names).find_each do |group|
- attrs = GROUP_ATTRS.inject({}) { |h, a| h[a] = group.send(a); h }
+ attrs = GROUP_ATTRS.inject({}) { |h, a| h[a] = group.public_send(a); h }
attrs[:user_ids] = group.users.pluck(:id)
groups << attrs
end
@@ -93,11 +93,18 @@ module ImportExport
@topics.each do |topic|
puts topic.title
- topic_data = TOPIC_ATTRS.inject({}) { |h, a| h[a] = topic.send(a); h; }
+ topic_data = TOPIC_ATTRS.inject({}) do |h, a|
+ h[a] = topic.public_send(a)
+ h
+ end
+
topic_data[:posts] = []
topic.ordered_posts.find_each do |post|
- attributes = POST_ATTRS.inject({}) { |h, a| h[a] = post.send(a); h; }
+ attributes = POST_ATTRS.inject({}) do |h, a|
+ h[a] = post.public_send(a)
+ h
+ end
attributes[:raw] = attributes[:raw].gsub(
'src="/uploads',
@@ -139,7 +146,12 @@ module ImportExport
users.find_each do |u|
next if u.id == Discourse::SYSTEM_USER_ID
- x = USER_ATTRS.inject({}) { |h, a| h[a] = u.send(a); h; }
+
+ x = USER_ATTRS.inject({}) do |h, a|
+ h[a] = u.public_send(a)
+ h
+ end
+
x.merge(bio_raw: u.user_profile.bio_raw,
website: u.user_profile.website,
location: u.user_profile.location)
diff --git a/lib/mini_sql_multisite_connection.rb b/lib/mini_sql_multisite_connection.rb
index 04fe3e1c9a8..280ee9e851f 100644
--- a/lib/mini_sql_multisite_connection.rb
+++ b/lib/mini_sql_multisite_connection.rb
@@ -19,7 +19,7 @@ class MiniSqlMultisiteConnection < MiniSql::Postgres::Connection
class ParamEncoder
def encode(*sql_array)
# use active record to avoid any discrepencies
- ActiveRecord::Base.send(:sanitize_sql_array, sql_array)
+ ActiveRecord::Base.public_send(:sanitize_sql_array, sql_array)
end
end
diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb
index 28dc167ebbc..8753ce61f1f 100644
--- a/lib/plugin/instance.rb
+++ b/lib/plugin/instance.rb
@@ -95,11 +95,11 @@ class Plugin::Instance
if define_include_method
# Don't include serialized methods if the plugin is disabled
- klass.send(:define_method, "include_#{attr}?") { plugin.enabled? }
+ klass.public_send(:define_method, "include_#{attr}?") { plugin.enabled? }
end
end
- klass.send(:define_method, attr, &block)
+ klass.public_send(:define_method, attr, &block)
end
end
@@ -170,10 +170,10 @@ class Plugin::Instance
reloadable_patch do |plugin|
klass = class_name.to_s.classify.constantize rescue class_name.to_s.constantize
hidden_method_name = :"#{attr}_without_enable_check"
- klass.send(:define_method, hidden_method_name, &block)
+ klass.public_send(:define_method, hidden_method_name, &block)
- klass.send(:define_method, attr) do |*args|
- send(hidden_method_name, *args) if plugin.enabled?
+ klass.public_send(:define_method, attr) do |*args|
+ public_send(hidden_method_name, *args) if plugin.enabled?
end
end
end
@@ -184,10 +184,10 @@ class Plugin::Instance
klass = klass_name.to_s.classify.constantize rescue klass_name.to_s.constantize
hidden_method_name = :"#{attr}_without_enable_check"
- klass.send(:define_singleton_method, hidden_method_name, &block)
+ klass.public_send(:define_singleton_method, hidden_method_name, &block)
- klass.send(:define_singleton_method, attr) do |*args|
- send(hidden_method_name, *args) if plugin.enabled?
+ klass.public_send(:define_singleton_method, attr) do |*args|
+ public_send(hidden_method_name, *args) if plugin.enabled?
end
end
end
@@ -200,10 +200,10 @@ class Plugin::Instance
method_name = "#{plugin.name}_#{klass.name}_#{callback}#{@idx}".underscore
@idx += 1
hidden_method_name = :"#{method_name}_without_enable_check"
- klass.send(:define_method, hidden_method_name, &block)
+ klass.public_send(:define_method, hidden_method_name, &block)
- klass.send(callback, options) do |*args|
- send(hidden_method_name, *args) if plugin.enabled?
+ klass.public_send(callback, options) do |*args|
+ public_send(hidden_method_name, *args) if plugin.enabled?
end
hidden_method_name
@@ -243,7 +243,7 @@ class Plugin::Instance
# Add validation method but check that the plugin is enabled
def validate(klass, name, &block)
klass = klass.to_s.classify.constantize
- klass.send(:define_method, name, &block)
+ klass.public_send(:define_method, name, &block)
plugin = self
klass.validate(name, if: -> { plugin.enabled? })
@@ -609,11 +609,11 @@ class Plugin::Instance
end
def extend_list_method(klass, method, new_attributes)
- current_list = klass.send(method)
+ current_list = klass.public_send(method)
current_list.concat(new_attributes)
reloadable_patch do
- klass.send(:define_singleton_method, method) { current_list }
+ klass.public_send(:define_singleton_method, method) { current_list }
end
end
diff --git a/lib/plugin/metadata.rb b/lib/plugin/metadata.rb
index 5f80ffc1159..5156bb23c14 100644
--- a/lib/plugin/metadata.rb
+++ b/lib/plugin/metadata.rb
@@ -95,7 +95,7 @@ class Plugin::Metadata
attribute = attribute.strip.gsub(/ /, '_').to_sym
if FIELDS.include?(attribute)
- self.send("#{attribute}=", description.strip)
+ self.public_send("#{attribute}=", description.strip)
end
end
diff --git a/lib/post_action_creator.rb b/lib/post_action_creator.rb
index 0ee475c1274..1638552a486 100644
--- a/lib/post_action_creator.rb
+++ b/lib/post_action_creator.rb
@@ -201,7 +201,7 @@ private
if post_action
post_action.recover!
- action_attrs.each { |attr, val| post_action.send("#{attr}=", val) }
+ action_attrs.each { |attr, val| post_action.public_send("#{attr}=", val) }
post_action.save
PostActionNotifier.post_action_created(post_action)
else
diff --git a/lib/post_creator.rb b/lib/post_creator.rb
index 91e7c79f488..380ce3b1de1 100644
--- a/lib/post_creator.rb
+++ b/lib/post_creator.rb
@@ -465,7 +465,7 @@ class PostCreator
# Attributes we pass through to the post instance if present
[:post_type, :no_bump, :cooking_options, :image_sizes, :acting_user, :invalidate_oneboxes, :cook_method, :via_email, :raw_email, :action_code].each do |a|
- post.send("#{a}=", @opts[a]) if @opts[a].present?
+ post.public_send("#{a}=", @opts[a]) if @opts[a].present?
end
post.extract_quoted_post_numbers
diff --git a/lib/post_revisor.rb b/lib/post_revisor.rb
index a177d57067a..fa9fd988c1a 100644
--- a/lib/post_revisor.rb
+++ b/lib/post_revisor.rb
@@ -226,7 +226,9 @@ class PostRevisor
def post_changed?
POST_TRACKED_FIELDS.each do |field|
- return true if @fields.has_key?(field) && @fields[field] != @post.send(field)
+ if @fields.has_key?(field) && @fields[field] != @post.public_send(field)
+ return true
+ end
end
advance_draft_sequence
false
@@ -362,7 +364,7 @@ class PostRevisor
end
POST_TRACKED_FIELDS.each do |field|
- @post.send("#{field}=", @fields[field]) if @fields.has_key?(field)
+ @post.public_send("#{field}=", @fields[field]) if @fields.has_key?(field)
end
@post.last_editor_id = @editor.id
diff --git a/lib/promotion.rb b/lib/promotion.rb
index 02935df148f..c10f2bbf855 100644
--- a/lib/promotion.rb
+++ b/lib/promotion.rb
@@ -47,7 +47,7 @@ class Promotion
if new_level < old_level && @user.manual_locked_trust_level.nil?
next_up = new_level + 1
key = "tl#{next_up}_met?"
- if self.class.respond_to?(key) && self.class.send(key, @user)
+ if self.class.respond_to?(key) && self.class.public_send(key, @user)
raise Discourse::InvalidAccess.new, I18n.t('trust_levels.change_failed_explanation',
user_name: @user.name,
new_trust_level: new_level,
diff --git a/lib/seed_data/categories.rb b/lib/seed_data/categories.rb
index abc4a615635..42e9fb40202 100644
--- a/lib/seed_data/categories.rb
+++ b/lib/seed_data/categories.rb
@@ -159,7 +159,11 @@ module SeedData
end
def find_category(site_setting_name)
+<<<<<<< HEAD
category_id = SiteSetting.get(site_setting_name)
+=======
+ category_id = SiteSetting.public_send(site_setting_name)
+>>>>>>> DEV: Prefer `public_send` over `send`.
Category.find_by(id: category_id) if category_id > 0
end
diff --git a/lib/single_sign_on.rb b/lib/single_sign_on.rb
index 51c44dbd8a2..8320c2ebbb7 100644
--- a/lib/single_sign_on.rb
+++ b/lib/single_sign_on.rb
@@ -81,7 +81,7 @@ class SingleSignOn
if BOOLS.include? k
val = ["true", "false"].include?(val) ? val == "true" : nil
end
- sso.send("#{k}=", val)
+ sso.public_send("#{k}=", val)
end
decoded_hash.each do |k, v|
diff --git a/lib/sql_builder.rb b/lib/sql_builder.rb
index f21ae4b1f87..d43da3dffc8 100644
--- a/lib/sql_builder.rb
+++ b/lib/sql_builder.rb
@@ -62,7 +62,7 @@ class SqlBuilder
sql = to_sql
if @klass
- @klass.find_by_sql(ActiveRecord::Base.send(:sanitize_sql_array, [sql, @args]))
+ @klass.find_by_sql(ActiveRecord::Base.public_send(:sanitize_sql_array, [sql, @args]))
else
if @args == {}
ActiveRecord::Base.exec_sql(sql)
diff --git a/lib/topic_creator.rb b/lib/topic_creator.rb
index e5e731ffa0a..f65f3023d45 100644
--- a/lib/topic_creator.rb
+++ b/lib/topic_creator.rb
@@ -92,7 +92,7 @@ class TopicCreator
else "track!"
end
- topic.notifier.send(action, gu.user_id)
+ topic.notifier.public_send(action, gu.user_id)
end
end
end
diff --git a/lib/topic_query.rb b/lib/topic_query.rb
index 85e3739b7d6..2a25c212cec 100644
--- a/lib/topic_query.rb
+++ b/lib/topic_query.rb
@@ -1033,6 +1033,6 @@ class TopicQuery
private
def sanitize_sql_array(input)
- ActiveRecord::Base.send(:sanitize_sql_array, input.join(','))
+ ActiveRecord::Base.public_send(:sanitize_sql_array, input.join(','))
end
end
diff --git a/lib/validators/upload_validator.rb b/lib/validators/upload_validator.rb
index e6c5fad25e2..bc6c2ca239f 100644
--- a/lib/validators/upload_validator.rb
+++ b/lib/validators/upload_validator.rb
@@ -125,6 +125,7 @@ class Validators::UploadValidator < ActiveModel::Validator
else
SiteSetting.get("max_#{type}_size_kb")
end
+
max_size_bytes = max_size_kb.kilobytes
if upload.filesize > max_size_bytes
diff --git a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb
index 9b685d9b38b..6e4d7e827c4 100644
--- a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb
+++ b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb
@@ -48,7 +48,13 @@ module DiscourseNarrativeBot
begin
old_data = @data.dup
- new_post = (@skip && @state != :end) ? skip_tutorial(next_state) : self.send(action)
+
+ new_post =
+ if (@skip && @state != :end)
+ skip_tutorial(next_state)
+ else
+ self.public_send(action)
+ end
if new_post
old_state = old_data[:state]
diff --git a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/new_user_narrative.rb b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/new_user_narrative.rb
index d26a61ae603..6d2f54c965e 100644
--- a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/new_user_narrative.rb
+++ b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/new_user_narrative.rb
@@ -532,7 +532,10 @@ module DiscourseNarrativeBot
end
def url_helpers(url, opts = {})
- Rails.application.routes.url_helpers.send(url, opts.merge(host: Discourse.base_url))
+ Rails.application.routes.url_helpers.public_send(
+ url,
+ opts.merge(host: Discourse.base_url)
+ )
end
end
end
diff --git a/plugins/discourse-nginx-performance-report/script/nginx_analyze.rb b/plugins/discourse-nginx-performance-report/script/nginx_analyze.rb
index 480beb67ebd..f974703d9b2 100644
--- a/plugins/discourse-nginx-performance-report/script/nginx_analyze.rb
+++ b/plugins/discourse-nginx-performance-report/script/nginx_analyze.rb
@@ -77,7 +77,7 @@ def top(cols, aggregator, count, aggregator_formatter = nil)
rows.each do |row|
cols.length.times do |i|
- print row[i].to_s.send(col_just[i], col_widths[i])
+ print row[i].to_s.public_send(col_just[i], col_widths[i])
print " "
end
puts
diff --git a/plugins/poll/lib/polls_updater.rb b/plugins/poll/lib/polls_updater.rb
index 26acdf14bd1..343611ee65a 100644
--- a/plugins/poll/lib/polls_updater.rb
+++ b/plugins/poll/lib/polls_updater.rb
@@ -57,8 +57,9 @@ module DiscoursePoll
# update poll
POLL_ATTRIBUTES.each do |attr|
- old_poll.send("#{attr}=", poll.send(attr))
+ old_poll.public_send("#{attr}=", poll.public_send(attr))
end
+
old_poll.save!
# keep track of anonymous votes
@@ -102,7 +103,7 @@ module DiscoursePoll
def self.is_different?(old_poll, new_poll, new_options)
# an attribute was changed?
POLL_ATTRIBUTES.each do |attr|
- return true if old_poll.send(attr) != new_poll.send(attr)
+ return true if old_poll.public_send(attr) != new_poll.public_send(attr)
end
# an option was changed?
diff --git a/script/import_scripts/base/csv_helper.rb b/script/import_scripts/base/csv_helper.rb
index e70f850bc4f..13a9fa37248 100644
--- a/script/import_scripts/base/csv_helper.rb
+++ b/script/import_scripts/base/csv_helper.rb
@@ -11,7 +11,7 @@ module ImportScripts
def initialize(cols)
cols.each_with_index do |col, idx|
- self.class.send(:define_method, col.downcase.gsub(/[\W]/, '_').squeeze('_')) do
+ self.class.public_send(:define_method, col.downcase.gsub(/[\W]/, '_').squeeze('_')) do
@row[idx]
end
end
diff --git a/script/import_scripts/bespoke_1.rb b/script/import_scripts/bespoke_1.rb
index 0607a616000..3d335338761 100644
--- a/script/import_scripts/bespoke_1.rb
+++ b/script/import_scripts/bespoke_1.rb
@@ -44,7 +44,7 @@ class ImportScripts::Bespoke < ImportScripts::Base
def initialize(cols)
cols.each_with_index do |col, idx|
- self.class.send(:define_method, col) do
+ self.class.public_send(:define_method, col) do
@row[idx]
end
end
diff --git a/script/import_scripts/jive.rb b/script/import_scripts/jive.rb
index 586e5443af8..1a9ead8480b 100644
--- a/script/import_scripts/jive.rb
+++ b/script/import_scripts/jive.rb
@@ -46,7 +46,7 @@ class ImportScripts::Jive < ImportScripts::Base
def initialize(cols)
cols.each_with_index do |col, idx|
- self.class.send(:define_method, col) do
+ self.class.public_send(:define_method, col) do
@row[idx]
end
end
diff --git a/script/memstats.rb b/script/memstats.rb
index 7d5d7b4072e..d70b8594a43 100755
--- a/script/memstats.rb
+++ b/script/memstats.rb
@@ -48,7 +48,7 @@ class Mapping
def initialize(lines)
FIELDS.each do |field|
- self.send("#{field}=", 0)
+ self.public_send("#{field}=", 0)
end
parse_first_line(lines.shift)
@@ -72,7 +72,7 @@ class Mapping
field = parts[0].downcase.sub(':', '')
if respond_to? "#{field}="
value = Float(parts[1]).to_i
- self.send("#{field}=", value)
+ self.public_send("#{field}=", value)
end
end
end
@@ -81,7 +81,7 @@ def consume_mapping(map_lines, totals)
m = Mapping.new(map_lines)
Mapping::FIELDS.each do |field|
- totals[field] += m.send(field)
+ totals[field] += m.public_send(field)
end
return m
end
diff --git a/spec/jobs/reindex_search_spec.rb b/spec/jobs/reindex_search_spec.rb
index 63a4b367a33..b7f5d8333c2 100644
--- a/spec/jobs/reindex_search_spec.rb
+++ b/spec/jobs/reindex_search_spec.rb
@@ -16,18 +16,19 @@ describe Jobs::ReindexSearch do
model = Fabricate(m.to_sym)
SiteSetting.default_locale = locale
subject.execute({})
- expect(model.send("#{m}_search_data").locale).to eq locale
+ expect(model.public_send("#{m}_search_data").locale).to eq locale
end
it "should rebuild `#{m}` when INDEX_VERSION changed" do
model = Fabricate(m.to_sym)
# so that search data can be reindexed
- search_data = model.send("#{m}_search_data")
+ search_data = model.public_send("#{m}_search_data")
search_data.update!(version: 0)
model.reload
subject.execute({})
- expect(model.send("#{m}_search_data").version).to eq SearchIndexer::INDEX_VERSION
+ expect(model.public_send("#{m}_search_data").version)
+ .to eq(SearchIndexer::INDEX_VERSION)
end
end
diff --git a/spec/mailers/user_notifications_spec.rb b/spec/mailers/user_notifications_spec.rb
index ca839c13514..e10b04e5e21 100644
--- a/spec/mailers/user_notifications_spec.rb
+++ b/spec/mailers/user_notifications_spec.rb
@@ -641,10 +641,13 @@ describe UserNotifications do
def expects_build_with(condition)
UserNotifications.any_instance.expects(:build_email).with(user.email, condition)
- mailer = UserNotifications.send(mail_type, user,
- notification_type: Notification.types[notification.notification_type],
- notification_data_hash: notification.data_hash,
- post: notification.post)
+ mailer = UserNotifications.public_send(
+ mail_type, user,
+ notification_type: Notification.types[notification.notification_type],
+ notification_data_hash: notification.data_hash,
+ post: notification.post
+ )
+
mailer.message
end
@@ -668,7 +671,8 @@ describe UserNotifications do
context "private_email" do
it "doesn't support reply by email" do
SiteSetting.private_email = true
- mailer = UserNotifications.send(
+
+ mailer = UserNotifications.public_send(
mail_type,
user,
notification_type: Notification.types[notification.notification_type],
diff --git a/spec/requests/notifications_controller_spec.rb b/spec/requests/notifications_controller_spec.rb
index 1777455b817..4db535fa18f 100644
--- a/spec/requests/notifications_controller_spec.rb
+++ b/spec/requests/notifications_controller_spec.rb
@@ -11,7 +11,7 @@ def create_notification(user_id, resp_code, matcher)
data: { message: 'tada' }.to_json
}
expect(response.status).to eq(resp_code)
- expect(Notification.count).send(matcher, eq(notification_count))
+ expect(Notification.count).public_send(matcher, eq(notification_count))
end
def update_notification(topic_id, resp_code, matcher)
@@ -19,7 +19,7 @@ def update_notification(topic_id, resp_code, matcher)
put "/notifications/#{notification.id}.json", params: { topic_id: topic_id }
expect(response.status).to eq(resp_code)
notification.reload
- expect(notification.topic_id).send(matcher, eq(topic_id))
+ expect(notification.topic_id).public_send(matcher, eq(topic_id))
end
def delete_notification(resp_code, matcher)
@@ -27,7 +27,7 @@ def delete_notification(resp_code, matcher)
notification_count = Notification.count
delete "/notifications/#{notification.id}.json"
expect(response.status).to eq(resp_code)
- expect(Notification.count).send(matcher, eq(notification_count))
+ expect(Notification.count).public_send(matcher, eq(notification_count))
end
describe NotificationsController do
diff --git a/spec/services/topic_status_updater_spec.rb b/spec/services/topic_status_updater_spec.rb
index 338fe122cf2..bb11cfbc248 100644
--- a/spec/services/topic_status_updater_spec.rb
+++ b/spec/services/topic_status_updater_spec.rb
@@ -78,7 +78,7 @@ describe TopicStatusUpdater do
topic = Fabricate(:topic, status_name => false)
updated = TopicStatusUpdater.new(topic, admin).update!(status_name, true)
expect(updated).to eq(true)
- expect(topic.send("#{status_name}?")).to eq(true)
+ expect(topic.public_send("#{status_name}?")).to eq(true)
updated = TopicStatusUpdater.new(topic, admin).update!(status_name, true)
expect(updated).to eq(false)
@@ -86,7 +86,7 @@ describe TopicStatusUpdater do
updated = TopicStatusUpdater.new(topic, admin).update!(status_name, false)
expect(updated).to eq(true)
- expect(topic.send("#{status_name}?")).to eq(false)
+ expect(topic.public_send("#{status_name}?")).to eq(false)
updated = TopicStatusUpdater.new(topic, admin).update!(status_name, false)
expect(updated).to eq(false)
diff --git a/spec/services/user_merger_spec.rb b/spec/services/user_merger_spec.rb
index f63d9238d30..b6a3616e566 100644
--- a/spec/services/user_merger_spec.rb
+++ b/spec/services/user_merger_spec.rb
@@ -462,7 +462,7 @@ describe UserMerger do
posts.each do |type, post|
post.reload
- expect(post.send("#{type}_count")).to eq(1)
+ expect(post.public_send("#{type}_count")).to eq(1)
end
end
end