Class: Canon::Config::MatchConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/canon/config.rb

Overview

Match configuration for comparison behavior

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(format = nil) ⇒ MatchConfig

Returns a new instance of MatchConfig.



115
116
117
118
119
# File 'lib/canon/config.rb', line 115

def initialize(format = nil)
  @format = format
  @resolver = build_resolver(format)
  @options = {}
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



113
114
115
# File 'lib/canon/config.rb', line 113

def options
  @options
end

Instance Method Details

#profileObject

Profile accessor with ENV override support



131
132
133
# File 'lib/canon/config.rb', line 131

def profile
  @resolver.resolve(:profile)
end

#profile=(value) ⇒ Object



135
136
137
# File 'lib/canon/config.rb', line 135

def profile=(value)
  @resolver.set_programmatic(:profile, value)
end

#reset!Object



125
126
127
128
# File 'lib/canon/config.rb', line 125

def reset!
  @resolver = build_resolver(@format)
  @options = {}
end

#to_hObject

Build match options from profile and options



140
141
142
143
144
145
# File 'lib/canon/config.rb', line 140

def to_h
  result = {}
  result[:match_profile] = profile if profile
  result[:match] = @options if @options && !@options.empty?
  result
end