Sha256: d8183441e5b85cb9a5e7cd38d6a87cc7ff3f903ddabef505dc1c32904ae9a4f3

Contents?: true

Size: 683 Bytes

Versions: 2

Compression:

Stored size: 683 Bytes

Contents

# frozen_string_literal: true

module LIT
  module Builder
    # @api private
    # @since 0.1.0
    class Map
      def initialize(mod, key_type, value_type)
        @type_checker = TypeChecker.new(mod)
        @key_type = key_type
        @value_type = value_type
      end

      def build
        type_checker = @type_checker
        key_type = @key_type
        value_type = @value_type

        Class.new(::LIT::Object::Map) do
          define_method(:check_type!) do |key, value|
            type_checker.check_type!(key_type, key)
            type_checker.check_type!(value_type, value)
          end

          private(:check_type!)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
litl-0.1.1 lib/lit/builder/map.rb
litl-0.1.0 lib/lit/builder/map.rb