Skip to content

Instantly share code, notes, and snippets.

@JRJurman
Last active December 17, 2015 19:19
Show Gist options
  • Select an option

  • Save JRJurman/5659462 to your computer and use it in GitHub Desktop.

Select an option

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
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
@JRJurman
Copy link
Copy Markdown
Author

updated gist, no longer uses #send method to call undef_method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment