Module: Labkit::Fields::Deprecated

Defined in:
lib/labkit/fields.rb

Constant Summary collapse

MAPPINGS =

This module tracks deprecated field names and maps them to their standard replacements. These mappings are used by the field scanner to identify and track usage of deprecated fields in the codebase.

{
  Fields::GL_USER_ID => %w[user_id userid],
  Fields::HTTP_STATUS_CODE => %w[status_code extra.status status_text],
}.freeze

Class Method Summary collapse

Class Method Details

.allHash{String => String}

Get all deprecated fields as a lookup hash

Returns:

  • (Hash{String => String})

    Hash mapping deprecated field names to standard field names



108
109
110
111
112
# File 'lib/labkit/fields.rb', line 108

def all
  @all ||= MAPPINGS.each_with_object({}) do |(key, values), result|
    values.each { |v| result[v] = key }
  end
end

.deprecated?(field_name) ⇒ Boolean

Check if a field is deprecated

Parameters:

  • field_name (String, Symbol)

    The field name to check

Returns:

  • (Boolean)

    true if the field is deprecated



118
119
120
# File 'lib/labkit/fields.rb', line 118

def deprecated?(field_name)
  all.key?(field_name.to_s)
end

.standard_field_for(deprecated_field) ⇒ String?

Get the standard field for a deprecated field

Parameters:

  • deprecated_field (String, Symbol)

    The deprecated field name

Returns:

  • (String, nil)

    The standard field name, or nil if not found



126
127
128
# File 'lib/labkit/fields.rb', line 126

def standard_field_for(deprecated_field)
  all[deprecated_field.to_s]
end