Last active
December 17, 2015 19:19
-
-
Save JRJurman/5659462 to your computer and use it in GitHub Desktop.
BlankSlate class which has only the reserved and protected methods
based on the builder example: https://github.com/jimweirich/builder/blob/master/lib/blankslate.rb
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 | |
| # BlankSlate provides a class with only the bare-bones recommended methods | |
| # without, you know, breaking ruby really really bad... | |
| # go through every method | |
| instance_methods.each do |func| | |
| # if it's a reserved method, don't remove it << these methods actually | |
| # prompt a warning if you try to remove them! | |
| if !func.match(/^(__|instance_eval|object_id)/) | |
| undef_method func | |
| end | |
| end | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated gist, no longer uses #send method to call undef_method