Created
June 1, 2014 03:34
-
-
Save k-tsj/8a161bda9b39c5c8d3d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/power_assert.rb b/lib/power_assert.rb | |
index 1a19d07..51064f1 100644 | |
--- a/lib/power_assert.rb | |
+++ b/lib/power_assert.rb | |
@@ -5,7 +5,23 @@ | |
require 'power_assert/version' | |
require 'ripper' | |
-require 'pattern-match' | |
+require 'pattern-match/core' | |
+ | |
+class << Array | |
+ include PatternMatch::Deconstructable | |
+ | |
+ def deconstruct(val) | |
+ accept_self_instance_only(val) | |
+ val | |
+ end | |
+ | |
+ private | |
+ | |
+ def accept_self_instance_only(val) | |
+ raise PatternMatch::PatternNotMatch unless val.kind_of?(self) | |
+ end | |
+end | |
+ | |
# NB: API is not fixed | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment