daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest May 27th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top