Skip to content

Instantly share code, notes, and snippets.

@enebo
Created June 13, 2011 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enebo/1023643 to your computer and use it in GitHub Desktop.
Save enebo/1023643 to your computer and use it in GitHub Desktop.
super in defined_method
class Base
def foo
puts "Base foo"
end
def bar
puts "Base bar"
end
end
class Derived < Base
def bar
self.class.send(:define_method, :foo) do
proc { super() }
end
end
end
d = Derived.new
code = d.bar
d.foo.call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment