Class: Lutaml::UmlRepository::SearchResult

Inherits:
Model::Serializable
  • Object
show all
Defined in:
lib/lutaml/uml_repository/search_result.rb

Overview

Immutable value object representing a search result.

Wraps a UML element (Class, Attribute, Association, etc.) with metadata about how it matched the search query.

Uses lutaml-model for automatic JSON/YAML serialization.

Examples:

Creating a search result

result = SearchResult.new(
  element: class_obj,
  element_type: :class,
  qualified_name: "ModelRoot::Package::ClassName",
  package_path: "ModelRoot::Package",
  match_field: :name,
  match_context: {}
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element_type:, qualified_name:, package_path:, match_field:, element: nil, match_context: nil) ⇒ SearchResult

Override initialize to accept element parameter

Parameters:

  • element (Object) (defaults to: nil)

    The UML element that matched

  • element_type (Symbol, String)

    Type of element

  • qualified_name (String)

    Fully qualified name

  • package_path (String)

    Package path

  • match_field (Symbol, String)

    Field that matched

  • match_context (Hash, nil) (defaults to: nil)

    Optional context



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/lutaml/uml_repository/search_result.rb', line 50

def initialize( # rubocop:disable Metrics/ParameterLists
  element_type:, qualified_name:, package_path:,
  match_field:, element: nil, match_context: nil
)
  # Store element before calling super (not for serialization)
  @element = element

  # Initialize lutaml-model with serializable attributes only
  super(
    element_type: element_type.to_s,
    qualified_name: qualified_name,
    package_path: package_path,
    match_field: match_field.to_s,
    match_context: match_context || {}
  )

  freeze
end

Instance Attribute Details

#elementObject (readonly)

The UML element that matched (not serialized - internal use only)



40
41
42
# File 'lib/lutaml/uml_repository/search_result.rb', line 40

def element
  @element
end