Created
August 21, 2010 01:29
-
-
Save ashrewdmint/541582 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Me | |
| include Parent | |
| def use_swimming_pool | |
| puts "This pool is so refreshing!" | |
| end | |
| def go_on_vacation | |
| expose :use_swimming_pool | |
| end | |
| def return_from_vacation | |
| conceal :use_swimming_pool | |
| end | |
| end | |
| class Neighbor | |
| include Adoptable | |
| def attempt_to(method) | |
| begin | |
| self.send method | |
| rescue | |
| puts "Oops, guess I can't do that" | |
| end | |
| end | |
| end | |
| me = Me.new | |
| bob = Neighbor.new | |
| me.adopt(bob) | |
| bob.attempt_to :use_swimming_pool # Can't do it! | |
| me.go_on_vacation | |
| bob.attempt_to :use_swimming_pool # This works | |
| me.return_from_vacation | |
| bob.attempt_to :use_swimming_pool # Can't do it! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment