diff options
| author | Markus Reiter | 2017-11-10 18:29:28 +0100 |
|---|---|---|
| committer | GitHub | 2017-11-10 18:29:28 +0100 |
| commit | 5318907d936d90b8d39473be288e5387e1032874 (patch) | |
| tree | b1653f5a3c355aa85d9b286a5888e28700f33450 /Library | |
| parent | d450b2fec793232226ae09db825a2ad8dab1becc (diff) | |
| parent | bd0b76329228986d1d461312989ec76c839d055b (diff) | |
| download | brew-5318907d936d90b8d39473be288e5387e1032874.tar.bz2 | |
Merge pull request #3432 from reitermarkus/delegate-class
Refactor `DependsOn` with `DelegateClass`.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb b/Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb index bdef4239a..5faac299f 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb @@ -2,7 +2,7 @@ require "rubygems" module Hbc class DSL - class DependsOn + class DependsOn < DelegateClass(Hash) VALID_KEYS = Set.new [ :formula, :cask, @@ -19,19 +19,18 @@ module Hbc }.freeze attr_accessor :java - attr_accessor :pairs attr_reader :arch, :cask, :formula, :macos, :x11 def initialize - @pairs ||= {} + super({}) @cask ||= [] @formula ||= [] end - def load(pairs = {}) + def load(**pairs) pairs.each do |key, value| raise "invalid depends_on key: '#{key.inspect}'" unless VALID_KEYS.include?(key) - @pairs[key] = send(:"#{key}=", *value) + self[key] = send(:"#{key}=", *value) end end @@ -90,14 +89,6 @@ module Hbc raise "invalid 'depends_on x11' value: #{arg.inspect}" unless [true, false].include?(arg) @x11 = arg end - - def to_yaml - @pairs.to_yaml - end - - def to_s - @pairs.inspect - end end end end |
