Class: LIT::Builder::Map Private

Inherits:
Object
  • Object
show all
Defined in:
lib/lit/builder/map.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(mod, key_type, value_type) ⇒ Map

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Map.

Since:

  • 0.1.0



8
9
10
11
12
# File 'lib/lit/builder/map.rb', line 8

def initialize(mod, key_type, value_type)
  @type_checker = TypeChecker.new(mod)
  @key_type = key_type
  @value_type = value_type
end

Instance Method Details

#buildObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lit/builder/map.rb', line 14

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