Commit 1de04fe9 authored by Jacopo's avatar Jacopo
Browse files

Updates code using class_methods over module ClassMethods

parent b66a9813a2c3
......@@ -26,7 +26,7 @@
module AtomicInternalId
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def has_internal_id(column, scope:, init:, presence: true) # rubocop:disable Naming/PredicateName
# We require init here to retain the ability to recalculate in the absence of a
# InternaLId record (we may delete records in `internal_ids` for example).
......
......@@ -12,7 +12,7 @@ module Awardable
end
end
module ClassMethods
class_methods do
def awarded(user, name)
sql = <<~EOL
EXISTS (
......
......@@ -4,7 +4,7 @@
module CaseSensitivity
extend ActiveSupport::Concern
module ClassMethods
class_methods do
# Queries the given columns regardless of the casing used.
#
# Unlike other ActiveRecord methods this method only operates on a Hash.
......
......@@ -3,7 +3,7 @@
module EachBatch
extend ActiveSupport::Concern
module ClassMethods
class_methods do
# Iterates over the rows in a relation in batches, similar to Rails'
# `in_batches` but in a more efficient way.
#
......
......@@ -14,7 +14,7 @@
module IgnorableColumn
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def columns
super.reject { |column| ignored_columns.include?(column.name) }
end
......
......@@ -118,7 +118,7 @@ def has_multiple_assignees?
end
end
module ClassMethods
class_methods do
# Searches for records with a matching title.
#
# This method uses ILIKE on PostgreSQL and LIKE on MySQL.
......
......@@ -3,7 +3,7 @@
module LoadedInGroupList
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def with_counts(archived:)
selects_including_counts = [
'namespaces.*',
......
......@@ -3,7 +3,7 @@
module ManualInverseAssociation
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def manual_inverse_association(association, inverse)
define_method(association) do |*args|
super(*args).tap do |value|
......
......@@ -10,7 +10,7 @@
module Mentionable
extend ActiveSupport::Concern
module ClassMethods
class_methods do
# Indicate which attributes of the Mentionable to search for GFM references.
def attr_mentionable(attr, options = {})
attr = attr.to_s
......
......@@ -3,7 +3,7 @@
module OptionallySearch
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def search(*)
raise(
NotImplementedError,
......
......@@ -26,7 +26,7 @@
module Participable
extend ActiveSupport::Concern
module ClassMethods
class_methods do
# Adds a list of participant attributes. Attributes can either be symbols or
# Procs.
#
......
......@@ -40,7 +40,7 @@ def referable_inspect
end
end
module ClassMethods
class_methods do
# The character that prefixes the actual reference identifier
#
# This should be overridden by the including class.
......
......@@ -20,7 +20,7 @@ module ResolvableNote
scope :unresolved, -> { resolvable.where(resolved_at: nil) }
end
module ClassMethods
class_methods do
# This method must be kept in sync with `#resolve!`
def resolve!(current_user)
unresolved.update_all(resolved_at: Time.now, resolved_by_id: current_user.id)
......
......@@ -3,7 +3,7 @@
module SelectForProjectAuthorization
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def select_for_project_authorization
select("projects.id AS project_id, members.access_level")
end
......
......@@ -3,7 +3,7 @@
module ShaAttribute
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def sha_attribute(name)
return if ENV['STATIC_VERIFICATION']
......
......@@ -19,7 +19,7 @@ module Sortable
scope :order_name_desc, -> { reorder(Arel::Nodes::Descending.new(arel_table[:name].lower)) }
end
module ClassMethods
class_methods do
def order_by(method)
case method.to_s
when 'created_asc' then order_created_asc
......
......@@ -3,7 +3,7 @@
module Spammable
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def attr_spammable(attr, options = {})
spammable_attrs << [attr.to_s, options]
end
......
......@@ -14,7 +14,7 @@
module StripAttribute
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def strip_attributes(*attrs)
strip_attrs.concat(attrs)
end
......
......@@ -11,7 +11,7 @@ module ApplicationWorker
set_queue
end
module ClassMethods
class_methods do
def inherited(subclass)
subclass.set_queue
end
......
......@@ -3,7 +3,7 @@
module WaitableWorker
extend ActiveSupport::Concern
module ClassMethods
class_methods do
# Schedules multiple jobs and waits for them to be completed.
def bulk_perform_and_wait(args_list, timeout: 10)
# Short-circuit: it's more efficient to do small numbers of jobs inline
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment