Meta Programming in Ruby
#class GoodTerminator
# likes_to_protect [:john_connor, :sarah_connor]
# likes_to_destroy []
#end
#
#class BadTerminator
# likes_to_protect []
# likes_to_destroy [:john_connor, :sarah_connor]
#end
- Implement a method "protects?" where you can pass in the name of a person to check if he protects them
- Create a method in the Terminatorable module called "good?" that will tell if a Terminator is good or bad
- Create a spec that if the Terminator is trying to destroy someone, they are bad
- Create the GoodTerminator and BadTerminator classes
- Update the specs to test the GoodTerminator and Bad Terminator
- Split the methods into
likes_to_protect
andlikes_to_destroy
- Alternatively, rename to
configuration
that accepts a hash of people to protect and people to destroy
Copyright: 2012 Jesse Wolgamott, MIT License (See LICENSE)