Class: Ace::Search::Molecules::PresetManager
- Inherits:
-
Object
- Object
- Ace::Search::Molecules::PresetManager
- 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
-
#exists?(name) ⇒ Boolean
Check if preset exists.
-
#get(name) ⇒ Object
Get a preset by name.
-
#initialize ⇒ PresetManager
constructor
A new instance of PresetManager.
-
#list ⇒ Object
List all available presets.
-
#merge_with_options(preset_name, options = {}) ⇒ Object
Merge preset with options Uses Config.merge() for consistent merge strategy support.
Constructor Details
#initialize ⇒ PresetManager
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
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 |
#list ⇒ Object
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 (preset_name, = {}) preset = get(preset_name) return 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() .to_h end |