aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/dsl/conflicts_with.rb
blob: dfaa55a5c2ee62a4b7f0ac1a511c03844308c954 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module Hbc
  class DSL
    class ConflictsWith
      VALID_KEYS = Set.new [
        :formula,
        :cask,
        :macos,
        :arch,
        :x11,
        :java,
      ]

      attr_reader *VALID_KEYS

      def initialize(pairs = {})
        @pairs = pairs

        VALID_KEYS.each do |key|
          instance_variable_set("@#{key}", Set.new)
        end

        pairs.each do |key, value|
          raise "invalid conflicts_with key: '#{key.inspect}'" unless VALID_KEYS.include?(key)
          instance_variable_set("@#{key}", instance_variable_get("@#{key}").merge([*value]))
        end
      end
    end
  end
end