-
-
Save gugod/118244 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 BlankSlate | |
| instance_methods.each { |m| undef_method m unless m =~ /^__/ } | |
| end | |
| class Stuff < BlankSlate | |
| def initialize(obj) | |
| @obj = obj | |
| end | |
| def to_s | |
| @obj.to_s | |
| end | |
| def method_missing(sym, *args, &block) | |
| return | |
| end | |
| end | |
| z = Stuff.new("bleh") | |
| # => ? | |
| puts "z => ?" | |
| puts z.class | |
| puts z.class.class | |
| puts (z.is_a?(Object) ? "is" : "not") + " an Object" | |
| puts z.__send__("class") | |
| puts z.inspect | |
| puts z | |
| z2 = z.clone | |
| puts "\nz2 => ?" | |
| puts z2.class | |
| puts z2.class.class | |
| puts (z2.is_a?(Object) ? "is" : "not") + " an Object" | |
| puts z2.__send__("class") | |
| puts z2.inspect | |
| puts z2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment