Skip to content

Instantly share code, notes, and snippets.

@mmartinson
Last active August 29, 2015 14:14
Show Gist options
  • Save mmartinson/79519aa29ccbd288e169 to your computer and use it in GitHub Desktop.
Save mmartinson/79519aa29ccbd288e169 to your computer and use it in GitHub Desktop.
Monkey patch warrior class for RubyWarrior Game
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