DEV: more send -> public_send changes
This is a work in progress commit for more send to public_send conversions Also adds some comments for cases where we need to keep send
This commit is contained in:
parent
61cc0f8c5f
commit
cac80cdc3b
|
@ -248,7 +248,7 @@ class ListController < ApplicationController
|
||||||
def top(options = nil)
|
def top(options = nil)
|
||||||
options ||= {}
|
options ||= {}
|
||||||
period = ListController.best_period_for(current_user.try(:previous_visit_at), options[:category])
|
period = ListController.best_period_for(current_user.try(:previous_visit_at), options[:category])
|
||||||
send("top_#{period}", options)
|
public_send("top_#{period}", options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def category_top
|
def category_top
|
||||||
|
|
|
@ -39,7 +39,7 @@ class AdminDashboardData
|
||||||
def problems
|
def problems
|
||||||
problems = []
|
problems = []
|
||||||
AdminDashboardData.problem_syms.each do |sym|
|
AdminDashboardData.problem_syms.each do |sym|
|
||||||
problems << send(sym)
|
problems << public_send(sym)
|
||||||
end
|
end
|
||||||
AdminDashboardData.problem_blocks.each do |blk|
|
AdminDashboardData.problem_blocks.each do |blk|
|
||||||
problems << instance_exec(&blk)
|
problems << instance_exec(&blk)
|
||||||
|
|
|
@ -16,6 +16,8 @@ module Trashable
|
||||||
#
|
#
|
||||||
scope = self.all
|
scope = self.all
|
||||||
|
|
||||||
|
# must use :send here cause predicates is protected
|
||||||
|
# careful with updates of this API
|
||||||
scope.where_clause.send(:predicates).delete(with_deleted_scope_sql)
|
scope.where_clause.send(:predicates).delete(with_deleted_scope_sql)
|
||||||
scope
|
scope
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,7 +33,7 @@ class IncomingLinksReport
|
||||||
report.limit = _opts[:limit].to_i if _opts[:limit]
|
report.limit = _opts[:limit].to_i if _opts[:limit]
|
||||||
report.category_id = _opts[:category_id] if _opts[:category_id]
|
report.category_id = _opts[:category_id] if _opts[:category_id]
|
||||||
|
|
||||||
send(report_method, report)
|
public_send(report_method, report)
|
||||||
report
|
report
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ class PostAction < ActiveRecord::Base
|
||||||
return @rate_limiter if @rate_limiter.present?
|
return @rate_limiter if @rate_limiter.present?
|
||||||
|
|
||||||
%w(like flag bookmark).each do |type|
|
%w(like flag bookmark).each do |type|
|
||||||
if send("is_#{type}?")
|
if public_send("is_#{type}?")
|
||||||
limit = SiteSetting.get("max_#{type}s_per_day")
|
limit = SiteSetting.get("max_#{type}s_per_day")
|
||||||
|
|
||||||
if is_like? && user && user.trust_level >= 2
|
if is_like? && user && user.trust_level >= 2
|
||||||
|
|
|
@ -169,7 +169,7 @@ class Report
|
||||||
begin
|
begin
|
||||||
wrap_slow_query do
|
wrap_slow_query do
|
||||||
if respond_to?(report_method)
|
if respond_to?(report_method)
|
||||||
send(report_method, report)
|
public_send(report_method, report)
|
||||||
elsif type =~ /_reqs$/
|
elsif type =~ /_reqs$/
|
||||||
req_report(report, type.split(/_reqs$/)[0].to_sym)
|
req_report(report, type.split(/_reqs$/)[0].to_sym)
|
||||||
else
|
else
|
||||||
|
|
|
@ -228,7 +228,7 @@ class Reviewable < ActiveRecord::Base
|
||||||
update_count = false
|
update_count = false
|
||||||
Reviewable.transaction do
|
Reviewable.transaction do
|
||||||
increment_version!(args[:version])
|
increment_version!(args[:version])
|
||||||
result = send(perform_method, performed_by, args)
|
result = public_send(perform_method, performed_by, args)
|
||||||
|
|
||||||
if result.success?
|
if result.success?
|
||||||
update_count = transition_to(result.transition_to, performed_by) if result.transition_to
|
update_count = transition_to(result.transition_to, performed_by) if result.transition_to
|
||||||
|
|
|
@ -15,6 +15,6 @@ class TopicPoster < OpenStruct
|
||||||
|
|
||||||
# TODO: Remove when old list is removed
|
# TODO: Remove when old list is removed
|
||||||
def [](attr)
|
def [](attr)
|
||||||
send(attr)
|
public_send(attr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,6 +23,7 @@ class TopicTimer < ActiveRecord::Base
|
||||||
!attribute_in_database(:execute_at).nil?) ||
|
!attribute_in_database(:execute_at).nil?) ||
|
||||||
will_save_change_to_user_id?
|
will_save_change_to_user_id?
|
||||||
|
|
||||||
|
# private implementation detail have to use send
|
||||||
self.send("cancel_auto_#{self.class.types[status_type]}_job")
|
self.send("cancel_auto_#{self.class.types[status_type]}_job")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -32,6 +33,7 @@ class TopicTimer < ActiveRecord::Base
|
||||||
now = Time.zone.now
|
now = Time.zone.now
|
||||||
time = execute_at < now ? now : execute_at
|
time = execute_at < now ? now : execute_at
|
||||||
|
|
||||||
|
# private implementation detail have to use send
|
||||||
self.send("schedule_auto_#{self.class.types[status_type]}_job", time)
|
self.send("schedule_auto_#{self.class.types[status_type]}_job", time)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -59,6 +61,7 @@ class TopicTimer < ActiveRecord::Base
|
||||||
TopicTimer.where("topic_timers.execute_at < ?", Time.zone.now)
|
TopicTimer.where("topic_timers.execute_at < ?", Time.zone.now)
|
||||||
.find_each do |topic_timer|
|
.find_each do |topic_timer|
|
||||||
|
|
||||||
|
# private implementation detail scoped to class
|
||||||
topic_timer.send(
|
topic_timer.send(
|
||||||
"schedule_auto_#{self.types[topic_timer.status_type]}_job",
|
"schedule_auto_#{self.types[topic_timer.status_type]}_job",
|
||||||
topic_timer.execute_at
|
topic_timer.execute_at
|
||||||
|
|
|
@ -64,6 +64,7 @@ class TranslationOverride < ActiveRecord::Base
|
||||||
|
|
||||||
def check_interpolation_keys
|
def check_interpolation_keys
|
||||||
original_text = I18n.overrides_disabled do
|
original_text = I18n.overrides_disabled do
|
||||||
|
# lookup is protected
|
||||||
I18n.backend.send(:lookup, self.locale, self.translation_key)
|
I18n.backend.send(:lookup, self.locale, self.translation_key)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ class TopListSerializer < ApplicationSerializer
|
||||||
attribute period
|
attribute period
|
||||||
|
|
||||||
define_method(period) do
|
define_method(period) do
|
||||||
if object.public_send(period)
|
if resolved = object.public_send(period)
|
||||||
TopicListSerializer.new(object.public_send(period), scope: scope).as_json
|
TopicListSerializer.new(resolved, scope: scope).as_json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class UserSerializer < BasicUserSerializer
|
||||||
method_name = "include_#{attr}?"
|
method_name = "include_#{attr}?"
|
||||||
define_method(method_name) do
|
define_method(method_name) do
|
||||||
return false if scope.restrict_user_fields?(object)
|
return false if scope.restrict_user_fields?(object)
|
||||||
send(attr).present?
|
public_send(attr).present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue