Sha256: 2916a484f1fd9c828d38f6a55473bed6f8e74a75c0e0cdc21fbda5307ee66a36

Contents?: true

Size: 986 Bytes

Versions: 4

Compression:

Stored size: 986 Bytes

Contents

# frozen_string_literal: true

require 'pathname'
require 'forwardable'
Dir[Pathname(__FILE__).dirname.join('method/*.rb').to_s].each(&method(:require))

module Masking
  class Config
    class TargetColumns
      class Method
        extend Forwardable

        def initialize(method)
          @method_type = mapping(method.class).new(method)
        end

        def_delegator :@method_type, :call

        private

        # rubocop:disable Layout/AlignHash
        MAPPING = {
          ::String     => StringBinaryDistinctor,
          ::Integer    => Integer,
          ::Float      => Float,
          ::Date       => Date,
          ::Time       => Time,
          ::TrueClass  => Boolean,
          ::FalseClass => Boolean,
          ::NilClass   => Null
        }.freeze
        # rubocop:enable Layout/AlignHash

        def mapping(klass)
          MAPPING[klass] || raise(UnknownType)
        end

        class UnknownType < RuntimeError; end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
masking-1.0.1 lib/masking/config/target_columns/method.rb
masking-1.0.0 lib/masking/config/target_columns/method.rb
masking-0.0.3 lib/masking/config/target_columns/method.rb
masking-0.0.2 lib/masking/config/target_columns/method.rb