Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
cooler redefine method
class Object
def redefine_method(meth)
return unless block_given?
oldmeth = self.instance_method(meth)
self.send(:define_method, meth) {|*args|
yield(oldmeth.bind(self), *args)
}
end
end
#=begin EXAMPLE
str = "cacca"
class String
def puts
STDOUT.puts self
end
end
str.puts
class String
redefine_method(:puts) {|old|
STDOUT.print "Hi, i'm "
old.call
}
end
str.puts
#=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.