Created
November 29, 2012 08:13
-
-
Save jeffreyiacono/4167524 to your computer and use it in GitHub Desktop.
fun with extending ruby modules ... or "how do we get mod === to pass without actually being an ancestor of the type"
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
| class SqlQuery; end | |
| query = SqlQuery.new | |
| puts "String === query is #{String === query}" | |
| #=> String === query is false | |
| String.extend Module.new { | |
| def ===(obj) | |
| obj.instance_of?(SqlQuery) or super | |
| end | |
| } | |
| puts "String === query is #{String === query}" | |
| #=> String === query is true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment