Class: Lutaml::Xsd::Conflicts::TypeConflict
- Inherits:
-
Model::Serializable
- Object
- Model::Serializable
- Lutaml::Xsd::Conflicts::TypeConflict
- Defined in:
- lib/lutaml/xsd/conflicts/type_conflict.rb
Overview
Type name conflict within a namespace
Instance Attribute Summary collapse
-
#sources ⇒ Object
Runtime-only.
Class Method Summary collapse
Instance Method Summary collapse
- #conflict_count ⇒ Object
- #detailed_description ⇒ Object
- #highest_priority_source ⇒ Object
- #qualified_name ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#sources ⇒ Object
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_count ⇒ Object
38 39 40 |
# File 'lib/lutaml/xsd/conflicts/type_conflict.rb', line 38 def conflict_count package_paths.size end |
#detailed_description ⇒ Object
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_source ⇒ Object
42 43 44 |
# File 'lib/lutaml/xsd/conflicts/type_conflict.rb', line 42 def highest_priority_source sources&.min_by(&:priority) end |
#qualified_name ⇒ Object
34 35 36 |
# File 'lib/lutaml/xsd/conflicts/type_conflict.rb', line 34 def qualified_name "{#{namespace_uri}}#{type_name}" end |
#to_s ⇒ Object
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 |