Class: Suma::LinkValidator::Step::Type

Inherits:
Object
  • Object
show all
Includes:
Failure
Defined in:
lib/suma/link_validator/step.rb

Overview

Navigates one path segment from a Type by either enumeration value (for enum types) or by re-targeting to the underlying named type (for non-enum types).

Constant Summary collapse

PRIMITIVE_TYPE_NAMES =
%w[INTEGER REAL STRING BOOLEAN NUMBER BINARY
LOGICAL].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Failure

#failure

Class Method Details

.handles?(node) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/suma/link_validator/step.rb', line 61

def self.handles?(node)
  node.is_a?(Expressir::Model::Declarations::Type)
end

Instance Method Details



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/suma/link_validator/step.rb', line 65

def navigate(node, part, context)
  underlying = node.underlying_type
  unless underlying
    return failure("Cannot navigate deeper from type '#{context.path}'",
                   context)
  end

  if underlying.is_a?(Expressir::Model::DataTypes::Enumeration)
    navigate_enum(underlying, part, context)
  else
    navigate_underlying(underlying, context)
  end
end