Skip to content

Instantly share code, notes, and snippets.

@jbranchaud
Last active August 29, 2015 14:25
Show Gist options
  • Save jbranchaud/dcf62d6f6b3a00c506c7 to your computer and use it in GitHub Desktop.
Save jbranchaud/dcf62d6f6b3a00c506c7 to your computer and use it in GitHub Desktop.
puts '====='
puts 'defining the Parent class with #poop'
class Parent
def poop
puts "💩 💩"
end
end
puts 'defining the Child < Parent class with #poop'
class Child < Parent
def poop
puts "💩 "
end
end
puts 'defining the Baby < Child class with #poop'
class Baby < Child
def poop
puts "💩 "
end
end
puts 'creating instances of each class'
child = Child.new
parent = Parent.new
baby = Baby.new
puts 'sending #poop to each class'
parent.poop
child.poop
baby.poop
puts '---'
puts "parent.respond_to?(:poop) -> #{parent.respond_to?(:poop)}"
puts "child.respond_to?(:poop) -> #{child.respond_to?(:poop)}"
puts "baby.respond_to?(:poop) -> #{baby.respond_to?(:poop)}"
puts 'opening baby to remove_method(:poop)'
class Baby
remove_method(:poop)
end
puts "parent.respond_to?(:poop) -> #{parent.respond_to?(:poop)}"
puts "child.respond_to?(:poop) -> #{child.respond_to?(:poop)}"
puts "baby.respond_to?(:poop) -> #{baby.respond_to?(:poop)}"
puts 'opening child to undef_method(:poop)'
class Child
undef_method(:poop)
end
puts "parent.respond_to?(:poop) -> #{parent.respond_to?(:poop)}"
puts "child.respond_to?(:poop) -> #{child.respond_to?(:poop)}"
puts "baby.respond_to?(:poop) -> #{baby.respond_to?(:poop)}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment