Class: ClaudeMemory::Recall::DualQueryTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/claude_memory/recall/dual_query_template.rb

Overview

Template for executing queries across both global and project databases Eliminates duplication of dual-database query patterns

Constant Summary collapse

SCOPE_ALL =
"all"
SCOPE_PROJECT =
"project"
SCOPE_GLOBAL =
"global"

Instance Method Summary collapse

Constructor Details

#initialize(manager) ⇒ DualQueryTemplate

Returns a new instance of DualQueryTemplate.



12
13
14
# File 'lib/claude_memory/recall/dual_query_template.rb', line 12

def initialize(manager)
  @manager = manager
end

Instance Method Details

#execute(scope:, limit: nil) {|store, source| ... } ⇒ Array

Execute a query operation across global and/or project stores based on scope

Parameters:

  • scope (String)

    One of: “all”, “project”, or “global”

  • limit (Integer) (defaults to: nil)

    Maximum results (used by deduplicator, not enforced here)

Yields:

  • (store, source)

    Yields each store with its source label

Returns:

  • (Array)

    Combined results from both stores



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/claude_memory/recall/dual_query_template.rb', line 22

def execute(scope:, limit: nil, &operation)
  results = []

  if should_query_project?(scope)
    results.concat(query_store(:project, &operation))
  end

  if should_query_global?(scope)
    results.concat(query_store(:global, &operation))
  end

  results
end