Skip to content

Instantly share code, notes, and snippets.

@NigelThorne
Created March 25, 2009 12:03
Show Gist options
  • Save NigelThorne/85437 to your computer and use it in GitHub Desktop.
Save NigelThorne/85437 to your computer and use it in GitHub Desktop.
require 'ruby2ruby'
def refactor(type, method, new_method)
m2 = Ruby2Ruby.translate(type, method).gsub("def #{method}", "def #{new_method}")
type.class_eval("remove_method method\n#{m2}")
end
class X
def z
5
end
end
refactor( X, "z", "y")
puts Ruby2Ruby.translate(X)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment