Class: ImproveYourCode::SmellConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/improve_your_code/smell_configuration.rb

Constant Summary collapse

ENABLED_KEY =
'enabled'
OVERRIDES_KEY =
'overrides'

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ SmellConfiguration

Returns a new instance of SmellConfiguration.



8
9
10
# File 'lib/improve_your_code/smell_configuration.rb', line 8

def initialize(hash)
  @options = hash
end

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/improve_your_code/smell_configuration.rb', line 16

def enabled?
  options[ENABLED_KEY]
end

#merge(new_options) ⇒ Object



12
13
14
# File 'lib/improve_your_code/smell_configuration.rb', line 12

def merge(new_options)
  options.merge!(new_options)
end

#overrides_for(context) ⇒ Object



20
21
22
# File 'lib/improve_your_code/smell_configuration.rb', line 20

def overrides_for(context)
  Overrides.new(options.fetch(OVERRIDES_KEY, {})).for_context(context)
end

#value(key, context) ⇒ Object



24
25
26
27
# File 'lib/improve_your_code/smell_configuration.rb', line 24

def value(key, context)
  overrides_for(context).each { |conf| return conf[key] if conf.key?(key) }
  options.fetch(key)
end