Last active
August 29, 2015 14:14
-
-
Save mmartinson/79519aa29ccbd288e169 to your computer and use it in GitHub Desktop.
Monkey patch warrior class for RubyWarrior Game
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
class TrainedWarrior | |
attr_accessor :fledgling | |
def initialize(warrior) | |
@fledgling = warrior | |
end | |
def method_missing(name, *args) | |
if fledgling.respond_to?(name) | |
result = fledgling.send(name, *args) | |
raise TurnOverError.new if name.to_s[-1] == '!' | |
result | |
else | |
super | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment