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],
}.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



77
78
79
80
81
# File 'lib/labkit/fields.rb', line 77

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



87
88
89
# File 'lib/labkit/fields.rb', line 87

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



95
96
97
# File 'lib/labkit/fields.rb', line 95

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