Sha256: d598f9ad9c2a0d0e5b6361d1f787146ef7f7bcf100b37353a6502e54f34c5949

Contents?: true

Size: 967 Bytes

Versions: 1

Compression:

Stored size: 967 Bytes

Contents

# frozen_string_literal: true

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

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

1 entries across 1 versions & 1 rubygems

Version Path
masking-0.0.1 lib/masking/config/target_columns/method.rb