Guest User

Untitled

a guest
May 27th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. class Module
  2. def alias_method_chain(target, feature)
  3. with_method, without_method = "#{target}_with_#{feature}", "#{target}_without_#{feature}"
  4.  
  5. alias_method without_method, target
  6. alias_method target, with_method
  7.  
  8. case
  9. when public_method_defined?(without_method)
  10. public target
  11. when protected_method_defined?(without_method)
  12. protected target
  13. when private_method_defined?(without_method)
  14. private target
  15. end
  16. end
  17. end
Add Comment
Please, Sign In to add comment