Sha256: 1ca90c352153dd1555bed5efd4757402d0b151799b15d126ec936f762667aa50

Contents?: true

Size: 631 Bytes

Versions: 1

Compression:

Stored size: 631 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.filter_map(all_flags, config:, from:)
        with_defaults(all_flags, config)
          .filter_map { |name, truthy| from[name] if truthy }
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bcdd-result-0.8.0 lib/bcdd/result/config/options.rb