Class: Ace::Search::Molecules::PresetManager

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/search/molecules/preset_manager.rb

Overview

Manages search presets from .ace/search/presets/*.yml files This is a molecule - composed operation using ace-config for config loading

Instance Method Summary collapse

Constructor Details

#initializePresetManager

Returns a new instance of PresetManager.



11
12
13
14
15
# File 'lib/ace/search/molecules/preset_manager.rb', line 11

def initialize
  @project_root = Ace::Support::Config.find_project_root || Dir.pwd
  @presets = {}
  load_presets
end

Instance Method Details

#exists?(name) ⇒ Boolean

Check if preset exists

Returns:

  • (Boolean)


28
29
30
# File 'lib/ace/search/molecules/preset_manager.rb', line 28

def exists?(name)
  @presets.key?(name.to_s)
end

#get(name) ⇒ Object

Get a preset by name



18
19
20
# File 'lib/ace/search/molecules/preset_manager.rb', line 18

def get(name)
  @presets[name.to_s]
end

#listObject

List all available presets



23
24
25
# File 'lib/ace/search/molecules/preset_manager.rb', line 23

def list
  @presets.keys.sort
end

#merge_with_options(preset_name, options = {}) ⇒ Object

Merge preset with options Uses Config.merge() for consistent merge strategy support



34
35
36
37
38
39
40
41
42
43
# File 'lib/ace/search/molecules/preset_manager.rb', line 34

def merge_with_options(preset_name, options = {})
  preset = get(preset_name)
  return options unless preset

  # Wrap preset in Config object to use Config.merge() consistently
  # This enables future per-key merge strategies via _merge directive
  Ace::Support::Config::Models::Config.new(preset, source: "preset:#{preset_name}")
    .merge(options)
    .to_h
end