Module: Solid::Result::Config::Options

Defined in:
lib/solid/result/config/options.rb

Class Method Summary collapse

Class Method Details

.addon(map:, from:) ⇒ Object



22
23
24
# File 'lib/solid/result/config/options.rb', line 22

def self.addon(map:, from:)
  select(map, config: :addon, from: from)
end

.select(all_flags, config:, from:) ⇒ Object



16
17
18
19
20
# File 'lib/solid/result/config/options.rb', line 16

def self.select(all_flags, config:, from:)
  with_defaults(all_flags, config)
    .filter_map { |name, truthy| [name, from[name]] if truthy }
    .to_h
end

.with_defaults(all_flags, config) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/solid/result/config/options.rb', line 6

def self.with_defaults(all_flags, config)
  all_flags ||= {}

  default_flags = Config.instance.to_h.fetch(config)

  config_flags = all_flags.fetch(config, {})

  default_flags.merge(config_flags).slice(*default_flags.keys)
end