Skip to content

Instantly share code, notes, and snippets.

@ashrewdmint
Created August 21, 2010 01:29
Show Gist options
  • Save ashrewdmint/541582 to your computer and use it in GitHub Desktop.
Save ashrewdmint/541582 to your computer and use it in GitHub Desktop.
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