Module: Rbs::Merge::NativeProjection

Defined in:
lib/rbs/merge/native_projection.rb

Overview

Produces the stable, location-free projection used for native RBS semantic verification and provider contract extension evidence.

Class Method Summary collapse

Class Method Details

.call(value) ⇒ Object

rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength -- native RBS values require recursive type dispatch



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rbs/merge/native_projection.rb', line 11

def call(value)
  case value
  when Array
    value.map { |item| call(item) }
  when Hash
    value.map { |key, item| [call(key), call(item)] }
  when String, Symbol, Numeric, true, false, nil
    value
  else
    attributes = value.instance_variables.reject { |name| i[@location @comment].include?(name) }
    [
      value.class.name,
      attributes.map { |name| [name, call(value.instance_variable_get(name))] }
    ]
  end
end