Sha256: a17085d4d6a4d3c336563070bdbbf7de789b0de24ff2bdb2dc9896b1c394475f

Contents?: true

Size: 647 Bytes

Versions: 8

Compression:

Stored size: 647 Bytes

Contents

# frozen_string_literal: true

class BCDD::Result
  class Config
    module Options
      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

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

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bcdd-result-1.1.0 lib/bcdd/result/config/options.rb
bcdd-result-1.0.0 lib/bcdd/result/config/options.rb
bcdd-result-0.13.0 lib/bcdd/result/config/options.rb
bcdd-result-0.12.0 lib/bcdd/result/config/options.rb
bcdd-result-0.11.0 lib/bcdd/result/config/options.rb
bcdd-result-0.10.0 lib/bcdd/result/config/options.rb
bcdd-result-0.9.1 lib/bcdd/result/config/options.rb
bcdd-result-0.9.0 lib/bcdd/result/config/options.rb