Skip to content

Instantly share code, notes, and snippets.

@indigoviolet
Last active December 23, 2017 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indigoviolet/08333c5df6759b9fa0bb59c4c365ae08 to your computer and use it in GitHub Desktop.
Save indigoviolet/08333c5df6759b9fa0bb59c4c365ae08 to your computer and use it in GitHub Desktop.
fin blog embed
# class is_a? seems to get confused sometimes because the class gets redefined somehow (?)
Contract.override_validator(:class) do |klass|
# We try hard not to do `constantize` because that is slow
lambda do |arg|
return true if arg.is_a?(klass)
return true if arg.class.name == klass.name
return true if arg.is_a?(klass.name.constantize)
return false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment