Last active
June 10, 2021 17:51
-
-
Save radixhound/c14af0572f309e4c490617ee27874f7e to your computer and use it in GitHub Desktop.
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
module SecretKey | |
protected | |
def fix_plumbing(*args) | |
_fix_plumbing(*args) if defined?(:_fix_plumbing) | |
end | |
def twist_knob | |
_twist_knob if defined?(:_twist_knob) | |
end | |
end | |
class Matt | |
include SecretKey | |
private | |
def _fix_plumbing(house) | |
house.twist_knob | |
end | |
end | |
class House | |
include SecretKey | |
private | |
def _twist_knob | |
puts "squeak squeak" | |
end | |
end | |
class Jessica | |
include SecretKey | |
def ask_for_repair(plumber, house) | |
plumber.fix_plumbing(house) | |
end | |
end | |
class Sam | |
def fix_plumbing(house) | |
house.twist_knob | |
end | |
def ask_for_repair(plumber, house) | |
plumber.fix_plumbing(house) | |
end | |
end | |
jessica = Jessica.new | |
matt = Matt.new | |
jessica.ask_for_repair(matt, House.new) | |
# Sam isn't allowed in on the secret | |
sam = Sam.new | |
sam.fix_plumbing(House.new) | |
sam.ask_for_repair(matt, House.new) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I feel excluded. 😢