Skip to content

Instantly share code, notes, and snippets.

@k-tsj
Created June 1, 2014 03:34
Show Gist options
  • Save k-tsj/8a161bda9b39c5c8d3d5 to your computer and use it in GitHub Desktop.
Save k-tsj/8a161bda9b39c5c8d3d5 to your computer and use it in GitHub Desktop.
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