Class: Jazzy::SymbolGraph::Relationship
- Inherits:
-
Object
- Object
- Jazzy::SymbolGraph::Relationship
- Defined in:
- lib/jazzy/symbol_graph/relationship.rb
Overview
A Relationship is a tidied-up SymbolGraph JSON object
Constant Summary collapse
- KINDS =
%w[memberOf conformsTo defaultImplementationOf overrides inheritsFrom requirementOf optionalRequirementOf].freeze
Instance Attribute Summary collapse
-
#constraints ⇒ Object
array, can be empty.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#source_usr ⇒ Object
Returns the value of attribute source_usr.
-
#target_fallback ⇒ Object
can be nil.
-
#target_usr ⇒ Object
Returns the value of attribute target_usr.
Instance Method Summary collapse
-
#actor_protocol? ⇒ Boolean
Protocol conformances added by compiler to actor decls that users aren’t interested in.
- #default_implementation? ⇒ Boolean
-
#initialize(hash) ⇒ Relationship
constructor
A new instance of Relationship.
- #protocol_requirement? ⇒ Boolean
Constructor Details
#initialize(hash) ⇒ Relationship
Returns a new instance of Relationship.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 31 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 |
Instance Attribute Details
#constraints ⇒ Object
array, can be empty
11 12 13 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 11 def constraints @constraints end |
#kind ⇒ Object
Returns the value of attribute kind.
7 8 9 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 7 def kind @kind end |
#source_usr ⇒ Object
Returns the value of attribute source_usr.
8 9 10 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 8 def source_usr @source_usr end |
#target_fallback ⇒ Object
can be nil
10 11 12 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 10 def target_fallback @target_fallback end |
#target_usr ⇒ Object
Returns the value of attribute target_usr.
9 10 11 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 9 def target_usr @target_usr end |
Instance Method Details
#actor_protocol? ⇒ Boolean
Protocol conformances added by compiler to actor decls that users aren’t interested in.
27 28 29 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 27 def actor_protocol? %w[Actor Sendable].include?(target_fallback) end |
#default_implementation? ⇒ Boolean
21 22 23 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 21 def default_implementation? kind == :defaultImplementationOf end |
#protocol_requirement? ⇒ Boolean
17 18 19 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 17 def protocol_requirement? %i[requirementOf optionalRequirementOf].include? kind end |