Class: Hbc::DSL::ConflictsWith

Inherits:
Object
  • Object
show all
Defined in:
Library/Homebrew/cask/lib/hbc/dsl/conflicts_with.rb

Constant Summary collapse

VALID_KEYS =
Set.new [
  :formula,
  :cask,
  :macos,
  :arch,
  :x11,
  :java,
]

Instance Method Summary collapse

Constructor Details

#initialize(pairs = {}) ⇒ ConflictsWith

Returns a new instance of ConflictsWith



15
16
17
18
19
20
21
22
23
24
25
26
# File 'Library/Homebrew/cask/lib/hbc/dsl/conflicts_with.rb', line 15

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