Class: Canon::Comparison::MatchOptions::BaseResolver
- Inherits:
-
Object
- Object
- Canon::Comparison::MatchOptions::BaseResolver
- Defined in:
- lib/canon/comparison/match_options/base_resolver.rb
Overview
Base class for match option resolvers Provides common resolve logic with format-specific customization
Direct Known Subclasses
Class Method Summary collapse
-
.format_defaults(format) ⇒ Hash
Get format-specific default options Subclasses should override this.
-
.get_profile_options(profile) ⇒ Hash
Get options for a named profile Subclasses should override this.
-
.match_dimensions ⇒ Array<Symbol>
Get valid match dimensions for this format Subclasses should override this.
-
.resolve(format:, match_profile: nil, match: nil, preprocessing: nil, global_profile: nil, global_options: nil) ⇒ Hash
Resolve match options with precedence handling.
Class Method Details
.format_defaults(format) ⇒ Hash
Get format-specific default options Subclasses should override this
71 72 73 74 |
# File 'lib/canon/comparison/match_options/base_resolver.rb', line 71 def format_defaults(format) raise NotImplementedError, "#{self.class} must implement #format_defaults" end |
.get_profile_options(profile) ⇒ Hash
Get options for a named profile Subclasses should override this
82 83 84 85 |
# File 'lib/canon/comparison/match_options/base_resolver.rb', line 82 def (profile) raise NotImplementedError, "#{self.class} must implement #get_profile_options" end |
.match_dimensions ⇒ Array<Symbol>
Get valid match dimensions for this format Subclasses should override this
91 92 93 94 |
# File 'lib/canon/comparison/match_options/base_resolver.rb', line 91 def match_dimensions raise NotImplementedError, "#{self.class} must implement #match_dimensions" end |
.resolve(format:, match_profile: nil, match: nil, preprocessing: nil, global_profile: nil, global_options: nil) ⇒ Hash
Resolve match options with precedence handling
Precedence order (highest to lowest):
-
Explicit match parameter
-
Profile from match_profile parameter
-
Global configuration
-
Format-specific defaults
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/canon/comparison/match_options/base_resolver.rb', line 25 def resolve(format:, match_profile: nil, match: nil, preprocessing: nil, global_profile: nil, global_options: nil) # Start with format-specific defaults = format_defaults(format).dup # Store format for later use (e.g., WhitespaceSensitivity needs it) [:format] = format # Apply global profile if specified if global_profile profile_opts = (global_profile) .merge!(profile_opts) end # Apply global options if specified if () .merge!() end # Apply per-call profile if specified (overrides global) if match_profile profile_opts = (match_profile) .merge!(profile_opts) end # Apply per-call preprocessing if specified (overrides profile) if preprocessing validate_preprocessing!(preprocessing) [:preprocessing] = preprocessing end # Apply per-call explicit options if specified (highest priority) if match (match) .merge!(match) end end |