Skip to content

Instantly share code, notes, and snippets.

@jeffreyiacono
Created November 29, 2012 08:13
Show Gist options
  • Select an option

  • Save jeffreyiacono/4167524 to your computer and use it in GitHub Desktop.

Select an option

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"
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