Module: Gitlab::GlobalId::Deprecations

Defined in:
lib/gitlab/global_id/deprecations.rb

Defined Under Namespace

Classes: Deprecation

Constant Summary collapse

DEPRECATIONS =

Contains the deprecations in place. Example:

DEPRECATIONS = [
  Deprecation.new(old_model_name: 'PrometheusService', new_model_name: 'Integrations::Prometheus', milestone: '14.1')
].freeze
[
  # This works around an accidentally released argument named as `"EEIterationID"` in 7000489db.
  Deprecation.new(old_model_name: 'EEIteration', new_model_name: 'Iteration', milestone: '13.3'),
  Deprecation.new(old_model_name: 'PrometheusService', new_model_name: 'Integrations::Prometheus', milestone: '14.1')
].freeze
OLD_NAME_MAP =

Maps of the DEPRECATIONS Hash for quick access.

DEPRECATIONS.index_by(&:old_model_name).freeze
NEW_NAME_MAP =
DEPRECATIONS.index_by(&:new_model_name).freeze
OLD_GRAPHQL_NAME_MAP =
DEPRECATIONS.index_by do |d|
  Types::GlobalIDType.model_name_to_graphql_name(d.old_model_name)
end.freeze

Class Method Summary collapse

Class Method Details

.apply_to_graphql_name(graphql_name) ⇒ Object

Returns the new `graphql_name` (Type#graphql_name) of a deprecated GID, or the `graphql_name` argument given if no deprecation applies.


41
42
43
44
45
# File 'lib/gitlab/global_id/deprecations.rb', line 41

def self.apply_to_graphql_name(graphql_name)
  return graphql_name unless deprecation = OLD_GRAPHQL_NAME_MAP[graphql_name]

  Types::GlobalIDType.model_name_to_graphql_name(deprecation.new_model_name)
end

.deprecated?(old_model_name) ⇒ Boolean

Returns:

  • (Boolean)

27
28
29
# File 'lib/gitlab/global_id/deprecations.rb', line 27

def self.deprecated?(old_model_name)
  OLD_NAME_MAP.key?(old_model_name)
end

.deprecation_by(new_model_name) ⇒ Object


35
36
37
# File 'lib/gitlab/global_id/deprecations.rb', line 35

def self.deprecation_by(new_model_name)
  NEW_NAME_MAP[new_model_name]
end

.deprecation_for(old_model_name) ⇒ Object


31
32
33
# File 'lib/gitlab/global_id/deprecations.rb', line 31

def self.deprecation_for(old_model_name)
  OLD_NAME_MAP[old_model_name]
end