Class: Lutaml::Xsd::Conflicts::TypeConflict

Inherits:
Model::Serializable
  • Object
show all
Defined in:
lib/lutaml/xsd/conflicts/type_conflict.rb

Overview

Type name conflict within a namespace

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sourcesObject

Runtime-only



21
22
23
# File 'lib/lutaml/xsd/conflicts/type_conflict.rb', line 21

def sources
  @sources
end

Class Method Details

.from_sources(namespace_uri:, type_name:, sources:) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/lutaml/xsd/conflicts/type_conflict.rb', line 23

def self.from_sources(namespace_uri:, type_name:, sources:)
  conflict = new(
    namespace_uri: namespace_uri,
    type_name: type_name,
    package_paths: sources.map(&:package_path),
    priorities: sources.map(&:priority),
  )
  conflict.sources = sources
  conflict
end

Instance Method Details

#conflict_countObject



38
39
40
# File 'lib/lutaml/xsd/conflicts/type_conflict.rb', line 38

def conflict_count
  package_paths.size
end

#detailed_descriptionObject



50
51
52
53
54
55
56
57
58
59
# File 'lib/lutaml/xsd/conflicts/type_conflict.rb', line 50

def detailed_description
  lines = []
  lines << "Type Name Conflict:"
  lines << "  Type: #{qualified_name}"
  lines << "  Defined in packages:"
  package_paths.each_with_index do |path, idx|
    lines << "    - #{path} (priority: #{priorities[idx]})"
  end
  lines.join("\n")
end

#highest_priority_sourceObject



42
43
44
# File 'lib/lutaml/xsd/conflicts/type_conflict.rb', line 42

def highest_priority_source
  sources&.min_by(&:priority)
end

#qualified_nameObject



34
35
36
# File 'lib/lutaml/xsd/conflicts/type_conflict.rb', line 34

def qualified_name
  "{#{namespace_uri}}#{type_name}"
end

#to_sObject



46
47
48
# File 'lib/lutaml/xsd/conflicts/type_conflict.rb', line 46

def to_s
  "Type '#{type_name}' in '{#{namespace_uri}}' defined in #{conflict_count} packages"
end