Class: LIT::Builder::Option Private

Inherits:
Object
  • Object
show all
Defined in:
lib/lit/builder/option.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, type) ⇒ Option

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 Option.

Since:

  • 0.1.0



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

def initialize(mod, type)
  @type_checker = TypeChecker.new(mod)
  @type = 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



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

def build
  mod = Module.new do
    include ::LIT::Object::Option
  end

  type_checker = @type_checker
  type = @type

  mod::Some.define_method(:check_type!) do |value|
    # NOTE: actually covered, but SimpleCov cannot detect that
    # :nocov:
    type_checker.check_type!(type, value)
    # :nocov:
  end

  mod
end