Last active
August 29, 2015 14:25
-
-
Save jbranchaud/dcf62d6f6b3a00c506c7 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
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
http://ruby-doc.org/core-1.9.3/Module.html#method-i-undef_method