aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2014-02-27 14:22:42 -0600
committerJack Nagel2014-02-27 14:22:42 -0600
commitb2ccbfe6af2adaf7cc4f0e2af691f428704d5658 (patch)
treec6b5086288f01f2bc50564780b2cfce93635f443 /Library
parent96df4fe1da62efe9be9f1a9b5d885672c8f09d75 (diff)
downloadbrew-b2ccbfe6af2adaf7cc4f0e2af691f428704d5658.tar.bz2
Add set union to Options
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/options.rb4
-rw-r--r--Library/Homebrew/test/test_options.rb7
2 files changed, 11 insertions, 0 deletions
diff --git a/Library/Homebrew/options.rb b/Library/Homebrew/options.rb
index 337281546..c3b15b06e 100644
--- a/Library/Homebrew/options.rb
+++ b/Library/Homebrew/options.rb
@@ -83,6 +83,10 @@ class Options
Options.new(@options & o)
end
+ def |(o)
+ Options.new(@options | o)
+ end
+
def *(arg)
@options.to_a * arg
end
diff --git a/Library/Homebrew/test/test_options.rb b/Library/Homebrew/test/test_options.rb
index 493aa100a..741581a01 100644
--- a/Library/Homebrew/test/test_options.rb
+++ b/Library/Homebrew/test/test_options.rb
@@ -126,6 +126,13 @@ class OptionsTests < Test::Unit::TestCase
assert_equal [foo], (@options & options).to_a
end
+ def test_set_union
+ foo, bar, baz = %w{foo bar baz}.map { |o| Option.new(o) }
+ options = Options.new << foo << bar
+ @options << foo << baz
+ assert_equal [foo, bar, baz].sort, (@options | options).to_a.sort
+ end
+
def test_coerce_with_options
assert_same @options, Options.coerce(@options)
end