Sha256: 78d8d3ce2e9aa95dc2646cfa012718703a82f428c9eb7b8900e58739f7def556

Contents?: true

Size: 646 Bytes

Versions: 2

Compression:

Stored size: 646 Bytes

Contents

# frozen_string_literal: true

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

      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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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