diff --git a/Library/Homebrew/cask/lib/hbc/container.rb b/Library/Homebrew/cask/lib/hbc/container.rb index c6b2c3c370..961e319686 100644 --- a/Library/Homebrew/cask/lib/hbc/container.rb +++ b/Library/Homebrew/cask/lib/hbc/container.rb @@ -61,7 +61,7 @@ module Hbc begin const_get(type.to_s.split("_").map(&:capitalize).join) rescue NameError - false + nil end end end diff --git a/Library/Homebrew/cask/lib/hbc/dsl/container.rb b/Library/Homebrew/cask/lib/hbc/dsl/container.rb index ab260c98cd..caaf25bcaf 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl/container.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl/container.rb @@ -1,3 +1,5 @@ +require "hbc/container" + module Hbc class DSL class Container @@ -13,9 +15,12 @@ module Hbc @pairs = pairs pairs.each do |key, value| raise "invalid container key: '#{key.inspect}'" unless VALID_KEYS.include?(key) - writer_method = "#{key}=".to_sym - send(writer_method, value) + send(:"#{key}=", value) end + + return if type.nil? + return unless Hbc::Container.from_type(type).nil? + raise "invalid container type: #{type.inspect}" end def to_yaml