Commit 05c26c74 authored by Jacopo's avatar Jacopo

Updates code using class_methods over module ClassMethods

parent 854445f4
......@@ -24,7 +24,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).
......
......@@ -10,7 +10,7 @@ module Awardable
end
end
module ClassMethods
class_methods do
def awarded(user, name)
sql = <<~EOL
EXISTS (
......
......@@ -2,7 +2,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.
......
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.
#
......
......@@ -12,7 +12,7 @@
module IgnorableColumn
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def columns
super.reject { |column| ignored_columns.include?(column.name) }
end
......
......@@ -115,7 +115,7 @@ module Issuable
end
end
module ClassMethods
class_methods do
# Searches for records with a matching title.
#
# This method uses ILIKE on PostgreSQL and LIKE on MySQL.
......
module LoadedInGroupList
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def with_counts(archived:)
selects_including_counts = [
'namespaces.*',
......
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|
......
......@@ -8,7 +8,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
......
......@@ -25,7 +25,7 @@ module Participable
extend ActiveSupport::Concern
prepend EE::Participable
module ClassMethods
class_methods do
# Adds a list of participant attributes. Attributes can either be symbols or
# Procs.
#
......
......@@ -38,7 +38,7 @@ module Referable
end
end
module ClassMethods
class_methods do
# The character that prefixes the actual reference identifier
#
# This should be overridden by the including class.
......
......@@ -18,7 +18,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)
......
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
......
module ShaAttribute
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def sha_attribute(name)
return if ENV['STATIC_VERIFICATION']
......
......@@ -16,7 +16,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
......
module Spammable
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def attr_spammable(attr, options = {})
spammable_attrs << [attr.to_s, options]
end
......
......@@ -12,7 +12,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
......
......@@ -4,7 +4,7 @@ module EE
extend ::Gitlab::Utils::Override
include ::Gitlab::Utils::StrongMemoize
module ClassMethods
class_methods do
extend ::Gitlab::Utils::Override
override :scalar_params
......
......@@ -7,7 +7,7 @@ module CustomModelNaming
self.class_attribute :singular_route_key, :route_key, :param_key
end
module ClassMethods
class_methods do
def model_name
@_model_name ||= begin
namespace = self.parents.detect do |n|
......
......@@ -85,7 +85,7 @@ module Elastic
end
end
module ClassMethods
class_methods do
# Should be overridden for all nested models
def nested?
false
......
......@@ -81,7 +81,7 @@ module EE
encode: true
end
module ClassMethods
class_methods do
extend ::Gitlab::Utils::Override
override :defaults
......
......@@ -6,7 +6,7 @@ module EE
module BroadcastMessage
extend ActiveSupport::Concern
module ClassMethods
class_methods do
extend ::Gitlab::Utils::Override
override :cache_expires_in
......
......@@ -28,7 +28,7 @@ module EE
end
end
module ClassMethods
class_methods do
# We support internal references (&epic_id) and cross-references (group.full_path&epic_id)
#
# Escaped versions with `&amp;` will be extracted too
......
......@@ -12,7 +12,7 @@ module EE
end
end
module ClassMethods
class_methods do
def uniqueness_scope
[*super, :saml_provider_id]
end
......
......@@ -70,7 +70,7 @@ module EE
project&.feature_available?(:issue_weights)
end
module ClassMethods
class_methods do
# override
def sort_by_attribute(method, excluded_labels: [])
case method.to_s
......
......@@ -41,7 +41,7 @@ module EE
before_create :sync_membership_lock_with_parent
end
module ClassMethods
class_methods do
def plans_with_feature(feature)
LICENSE_PLANS_TO_NAMESPACE_PLANS.values_at(*License.plans_with_feature(feature))
end
......
......@@ -81,7 +81,7 @@ module EE
end
end
module ClassMethods
class_methods do
def search_by_visibility(level)
where(visibility_level: ::Gitlab::VisibilityLevel.string_options[level])
end
......
......@@ -2,7 +2,7 @@ module EE
module ProjectAuthorization
extend ActiveSupport::Concern
module ClassMethods
class_methods do
# Get amout of users with highest role they have.
# If John is developer in one project but maintainer in another he will be
# counted once as maintainer. This is needed to count users who don't use
......
......@@ -2,7 +2,7 @@ module EE
module Service
extend ActiveSupport::Concern
module ClassMethods
class_methods do
extend ::Gitlab::Utils::Override
override :available_services_names
......
......@@ -45,7 +45,7 @@ module EE
enum roadmap_layout: { weeks: 1, months: 4, quarters: 12 }
end
module ClassMethods
class_methods do
def support_bot
email_pattern = "support%s@#{Settings.gitlab.host}"
......
......@@ -8,7 +8,7 @@ module EE
module EpicReferenceFilter
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def references_in(text, pattern = object_class.reference_pattern)
text.gsub(pattern) do |match|
symbol = $~[object_sym]
......
......@@ -400,7 +400,7 @@ module Elasticsearch
end
end
module ClassMethods
class_methods do
def search(query, type: :all, page: 1, per: 20, options: {})
results = { blobs: [], commits: [] }
......
......@@ -85,7 +85,7 @@ module API
end
end
module ClassMethods
class_methods do
private
def install_error_responders(base)
......
......@@ -2,7 +2,7 @@ module API
module ProjectsRelationBuilder
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def prepare_relation(projects_relation, options = {})
projects_relation = preload_relation(projects_relation, options)
execute_batch_counting(projects_relation)
......
......@@ -6,7 +6,7 @@ module Gitlab
module ExposeAttribute
extend ActiveSupport::Concern
module ClassMethods
class_methods do
# Defines getter methods for the given attribute names.
#
# Example:
......
......@@ -5,7 +5,7 @@ module Gitlab
module MountMutation
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def mount_mutation(mutation_class)
# Using an underscored field name symbol will make `graphql-ruby`
# standardize the field name
......
......@@ -2,7 +2,7 @@
module StaticModel
extend ActiveSupport::Concern
module ClassMethods
class_methods do
# Used by ActiveRecord's polymorphic association to set object_id
def primary_key
'id'
......
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