Last active
June 26, 2019 22:30
-
-
Save matthewrudy/62bf3be9580fc03566318c40fff79aee to your computer and use it in GitHub Desktop.
Example of a module that expects the classes including it to have certain methods implemented
This file contains 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
# typed: true | |
class AdminLogin | |
include Loginable | |
def email | |
'[email protected]' | |
end | |
end | |
module Loginable | |
include Kernel | |
def log_in!(password) | |
puts <<~MSG | |
logging in: | |
email: #{email} | |
password: #{password} | |
MSG | |
end | |
# sometimes I do this | |
# but not all circumstances make sense | |
# | |
# def email | |
# raise NotImplementedError | |
# end | |
# this is a hack to make it pass | |
# but is annoying if you don't own the method signature | |
# | |
# def email | |
# super | |
# end | |
end |
This file contains 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
editor.rb:17: Method email does not exist on Loginable https://srb.help/7003 | |
17 | email: #{email} | |
^^^^^ | |
https://github.com/sorbet/sorbet/tree/90c20f728c528aa4a1a3dc1a137e4c9eae95716d/rbi/core/kernel.rbi#L96: Did you mean: Kernel#eval? | |
96 | def eval(arg0, arg1=T.unsafe(nil), filename=T.unsafe(nil), lineno=T.unsafe(nil)); end | |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
Errors: 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment