class Jazzy::SymbolGraph::Relationship
A Relationship
is a tidied-up SymbolGraph
JSON object
Constants
- KINDS
Order matters: defaultImplementationOf after the protocols have been defined; extensionTo after all the extensions have been discovered.
- KINDS_INDEX
Attributes
constraints[RW]
kind[RW]
source_usr[RW]
target_fallback[RW]
target_usr[RW]
Public Class Methods
new(hash)
click to toggle source
# File lib/jazzy/symbol_graph/relationship.rb, line 40 def initialize(hash) kind = hash[:kind] unless KINDS.include?(kind) raise "Unknown relationship kind '#{kind}'" end self.kind = kind.to_sym self.source_usr = hash[:source] self.target_usr = hash[:target] if fallback = hash[:targetFallback] # Strip the leading module name self.target_fallback = fallback.sub(/^.*?\./, '') end self.constraints = Constraint.new_list(hash[:swiftConstraints] || []) end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/jazzy/symbol_graph/relationship.rb, line 59 def <=>(other) return 0 if kind == other.kind KINDS_INDEX[kind] <=> KINDS_INDEX[other.kind] end
actor_protocol?()
click to toggle source
Protocol conformances added by compiler to actor decls that users aren’t interested in.
# File lib/jazzy/symbol_graph/relationship.rb, line 36 def actor_protocol? %w[Actor AnyActor Sendable].include?(target_fallback) end
default_implementation?()
click to toggle source
# File lib/jazzy/symbol_graph/relationship.rb, line 26 def default_implementation? kind == :defaultImplementationOf end
extension_to?()
click to toggle source
# File lib/jazzy/symbol_graph/relationship.rb, line 30 def extension_to? kind == :extensionTo end
protocol_requirement?()
click to toggle source
# File lib/jazzy/symbol_graph/relationship.rb, line 22 def protocol_requirement? %i[requirementOf optionalRequirementOf].include? kind end