Sha256: cbf3c9aa297b36074f8b10d7bf4005b5136e5fda50e333c62a7ec061309a0fbc

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require 'masking/config/target_columns/method'

module Masking
  class Config
    class TargetColumns
      class Column
        attr_reader :table_name, :method_value, :method

        def initialize(name, table_name:, method_value:)
          raise ColumnNameIsNil if name.nil?

          @original_name = name.to_sym
          @table_name    = table_name.to_sym
          @method_value  = method_value
          @method        = Method.new(method_value, ignore_null: ignore_null?)
        end

        def ==(other)
          name == other.name && table_name == other.table_name && method_value == other.method_value
        end

        def name
          @name ||= ignore_null? ? original_name.to_s.chomp(IGNORE_NULL_SUFFIX).to_sym : original_name
        end

        def ignore_null?
          @ignore_null ||= original_name.to_s.end_with?(IGNORE_NULL_SUFFIX)
        end

        class ColumnNameIsNil < StandardError; end

        private

        attr_reader :original_name

        IGNORE_NULL_SUFFIX = '?'
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
masking-1.1.2 lib/masking/config/target_columns/column.rb
masking-1.1.2.pre.alpha lib/masking/config/target_columns/column.rb
masking-1.1.1 lib/masking/config/target_columns/column.rb