mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 02:32:45 +08:00
Remove threequals from ruby files
This commit is contained in:
parent
2beaeed36d
commit
38882eb1a7
|
@ -276,11 +276,11 @@ SQL
|
||||||
full = CategoryGroup.permission_types[:full]
|
full = CategoryGroup.permission_types[:full]
|
||||||
|
|
||||||
mapped = permissions.map do |group,permission|
|
mapped = permissions.map do |group,permission|
|
||||||
group = group.id if Group === group
|
group = group.id if group.is_a?(Group)
|
||||||
|
|
||||||
# subtle, using Group[] ensures the group exists in the DB
|
# subtle, using Group[] ensures the group exists in the DB
|
||||||
group = Group[group.to_sym].id unless Fixnum === group
|
group = Group[group.to_sym].id unless group.is_a?(Fixnum)
|
||||||
permission = CategoryGroup.permission_types[permission] unless Fixnum === permission
|
permission = CategoryGroup.permission_types[permission] unless permission.is_a?(Fixnum)
|
||||||
|
|
||||||
[group, permission]
|
[group, permission]
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ class CategoryFeaturedUser < ActiveRecord::Base
|
||||||
|
|
||||||
def self.feature_users_in(category_or_category_id)
|
def self.feature_users_in(category_or_category_id)
|
||||||
category_id =
|
category_id =
|
||||||
if Fixnum === category_or_category_id
|
if category_or_category_id.is_a?(Fixnum)
|
||||||
category_or_category_id
|
category_or_category_id
|
||||||
else
|
else
|
||||||
category_or_category_id.id
|
category_or_category_id.id
|
||||||
|
|
|
@ -66,13 +66,12 @@ class TopicUser < ActiveRecord::Base
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(topic,user)
|
def get(topic, user)
|
||||||
topic = topic.id if Topic === topic
|
topic = topic.id if topic.is_a?(Topic)
|
||||||
user = user.id if User === user
|
user = user.id if user.is_a?(User)
|
||||||
TopicUser.where('topic_id = ? and user_id = ?', topic, user).first
|
TopicUser.find_by(topic_id: topic, user_id: user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# Change attributes for a user (creates a record when none is present). First it tries an update
|
# Change attributes for a user (creates a record when none is present). First it tries an update
|
||||||
# since there's more likely to be an existing record than not. If the update returns 0 rows affected
|
# since there's more likely to be an existing record than not. If the update returns 0 rows affected
|
||||||
# it then creates the row instead.
|
# it then creates the row instead.
|
||||||
|
@ -117,8 +116,8 @@ class TopicUser < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def track_visit!(topic,user)
|
def track_visit!(topic,user)
|
||||||
topic_id = Topic === topic ? topic.id : topic
|
topic_id = topic.is_a?(Topic) ? topic.id : topic
|
||||||
user_id = User === user ? user.id : topic
|
user_id = user.is_a?(User) ? user.id : topic
|
||||||
|
|
||||||
now = DateTime.now
|
now = DateTime.now
|
||||||
rows = TopicUser.where({topic_id: topic_id, user_id: user_id}).update_all({last_visited_at: now})
|
rows = TopicUser.where({topic_id: topic_id, user_id: user_id}).update_all({last_visited_at: now})
|
||||||
|
|
|
@ -200,7 +200,7 @@ class User < ActiveRecord::Base
|
||||||
def approve(approved_by, send_mail=true)
|
def approve(approved_by, send_mail=true)
|
||||||
self.approved = true
|
self.approved = true
|
||||||
|
|
||||||
if Fixnum === approved_by
|
if approved_by.is_a?(Fixnum)
|
||||||
self.approved_by_id = approved_by
|
self.approved_by_id = approved_by
|
||||||
else
|
else
|
||||||
self.approved_by = approved_by
|
self.approved_by = approved_by
|
||||||
|
|
|
@ -197,7 +197,7 @@ class Guardian
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_send_private_message?(target)
|
def can_send_private_message?(target)
|
||||||
(User === target || Group === target) &&
|
(target.is_a?(Group) || target.is_a?(User)) &&
|
||||||
# User is authenticated
|
# User is authenticated
|
||||||
authenticated? &&
|
authenticated? &&
|
||||||
# Can't send message to yourself
|
# Can't send message to yourself
|
||||||
|
@ -221,7 +221,7 @@ class Guardian
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_me?(other)
|
def is_me?(other)
|
||||||
other && authenticated? && User === other && @user == other
|
other && authenticated? && other.is_a?(User) && @user == other
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_not_me?(other)
|
def is_not_me?(other)
|
||||||
|
|
|
@ -96,13 +96,13 @@ module JsLocaleHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.strip_out_message_formats!(hash, prefix = "", rval = {})
|
def self.strip_out_message_formats!(hash, prefix = "", rval = {})
|
||||||
if Hash === hash
|
if hash.is_a?(Hash)
|
||||||
hash.each do |k,v|
|
hash.each do |key, value|
|
||||||
if Hash === v
|
if value.is_a?(Hash)
|
||||||
rval.merge!(strip_out_message_formats!(v, prefix + (prefix.length > 0 ? "." : "") << k, rval))
|
rval.merge!(strip_out_message_formats!(value, prefix + (prefix.length > 0 ? "." : "") << key, rval))
|
||||||
elsif k.to_s().end_with?("_MF")
|
elsif key.to_s.end_with?("_MF")
|
||||||
rval[prefix + (prefix.length > 0 ? "." : "") << k] = v
|
rval[prefix + (prefix.length > 0 ? "." : "") << key] = value
|
||||||
hash.delete(k)
|
hash.delete(key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,7 +47,7 @@ class Search
|
||||||
@limit = Search.per_facet * Search.facets.size
|
@limit = Search.per_facet * Search.facets.size
|
||||||
@results = GroupedSearchResults.new(@opts[:type_filter])
|
@results = GroupedSearchResults.new(@opts[:type_filter])
|
||||||
|
|
||||||
if Topic === @search_context && @search_context.posts_count < SiteSetting.min_posts_for_search_in_topic
|
if @search_context.is_a?(Topic) && @search_context.posts_count < SiteSetting.min_posts_for_search_in_topic
|
||||||
@search_context = nil
|
@search_context = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -191,7 +191,7 @@ module SiteSettingExtension
|
||||||
val = (val == "t" || val == "true") ? 't' : 'f'
|
val = (val == "t" || val == "true") ? 't' : 'f'
|
||||||
end
|
end
|
||||||
|
|
||||||
if type == types[:fixnum] && !(Fixnum === val)
|
if type == types[:fixnum] && !val.is_a?(Fixnum)
|
||||||
val = val.to_i
|
val = val.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ task "qunit:test" => :environment do
|
||||||
|
|
||||||
# A bit of a hack until we can figure this out on Travis
|
# A bit of a hack until we can figure this out on Travis
|
||||||
tries = 0
|
tries = 0
|
||||||
while tries < 3 && $?.exitstatus === 124 && !quit
|
while tries < 3 && $?.exitstatus == 124 && !quit
|
||||||
tries += 1
|
tries += 1
|
||||||
puts "\nTimed Out. Trying again...\n"
|
puts "\nTimed Out. Trying again...\n"
|
||||||
rake_system(cmd)
|
rake_system(cmd)
|
||||||
|
|
|
@ -28,7 +28,7 @@ module Helpers
|
||||||
args[:title] ||= "This is my title #{Helpers.next_seq}"
|
args[:title] ||= "This is my title #{Helpers.next_seq}"
|
||||||
user = args.delete(:user) || Fabricate(:user)
|
user = args.delete(:user) || Fabricate(:user)
|
||||||
guardian = Guardian.new(user)
|
guardian = Guardian.new(user)
|
||||||
args[:category] = args[:category].name if Category === args[:category]
|
args[:category] = args[:category].name if args[:category].is_a?(Category)
|
||||||
TopicCreator.create(user, guardian, args)
|
TopicCreator.create(user, guardian, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ module Helpers
|
||||||
args[:raw] ||= "This is the raw body of my post, it is cool #{Helpers.next_seq}"
|
args[:raw] ||= "This is the raw body of my post, it is cool #{Helpers.next_seq}"
|
||||||
args[:topic_id] = args[:topic].id if args[:topic]
|
args[:topic_id] = args[:topic].id if args[:topic]
|
||||||
user = args.delete(:user) || Fabricate(:user)
|
user = args.delete(:user) || Fabricate(:user)
|
||||||
args[:category] = args[:category].name if Category === args[:category]
|
args[:category] = args[:category].name if args[:category].is_a?(Category)
|
||||||
PostCreator.create(user, args)
|
PostCreator.create(user, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user