Skip to content

Instantly share code, notes, and snippets.

@tal
Created September 21, 2011 20:13
Show Gist options
  • Select an option

  • Save tal/1233155 to your computer and use it in GitHub Desktop.

Select an option

Save tal/1233155 to your computer and use it in GitHub Desktop.
Ruby Fu
class Foo
def t
puts "Foo"
end
end
module T
def t
puts "T"
super
end
end
module TT
end
class Bar < Foo
include T
include TT
TT.instance_eval do
define_method :t do
puts "TT"
super
end
end
def t
puts "Bar"
super
end
end
Bar.new.t
puts '-'*15
Bar.class_eval do
def foo
puts 'class'
end
end
Bar.instance_eval do
def foo
puts 'instance'
end
end
Bar.new.foo
Bar.foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment