Class: Lutaml::UmlRepository::QueryDSL::Conditions::PackageCondition

Inherits:
BaseCondition
  • Object
show all
Defined in:
lib/lutaml/uml_repository/query_dsl/conditions/package_condition.rb

Overview

Package-based condition for filtering by package membership

Filters results based on package path, with support for recursive (descendant) matching.

Examples:

Filter by exact package

condition = PackageCondition.new(
"ModelRoot::i-UR", recursive: false)
filtered = condition.apply(classes)

Filter by package and descendants

condition = PackageCondition.new("ModelRoot::i-UR", recursive: true)
filtered = condition.apply(classes)

Instance Method Summary collapse

Constructor Details

#initialize(package_path, recursive: false) ⇒ PackageCondition

Initialize with package path and recursion setting

The package path to filter by

Parameters:

  • package_path (String, PackagePath)
  • recursive (Boolean) (defaults to: false)

    Whether to include descendants



29
30
31
32
33
34
35
36
37
# File 'lib/lutaml/uml_repository/query_dsl/conditions/package_condition.rb', line 29

def initialize(package_path, recursive: false)
  super()
  @package_path = if package_path.is_a?(PackagePath)
                    package_path
                  else
                    PackagePath.new(package_path)
                  end
  @recursive = recursive
end

Instance Method Details

#apply(results) ⇒ Array

Apply package-based filtering to results

Parameters:

  • results (Array)

    The collection to filter

Returns:

  • (Array)

    Objects in the specified package



43
44
45
46
47
# File 'lib/lutaml/uml_repository/query_dsl/conditions/package_condition.rb', line 43

def apply(results)
  results.select do |obj|
    matches_package?(obj)
  end
end