Time.now - self*3600 end end end class Foo using FixnumExtras end class Bar < Foo def hello 10.hours_ago end end a = Bar.new() a.hello() Monday, 21 January 13
object. module StringExtras refine String do def wow puts "Called wow" end end end using StringExtras class Foo def hello "hello".wow() end end a = Foo.new() a.hello Monday, 21 January 13
end class Bar < Foo def hello puts "hello from bar" end end class Foo def hello puts "overridden definition of hello" end end module FooExtensions def self.included(base) base.undef_method :hello end def hello puts "Hello from Foo extensions" end end Foo.send(:include,FooExtensions) Monday, 21 January 13
end end module FooExtensions def hello puts "Hello from Foo extensions" end end Foo.send(:prepend, FooExtensions) a = Foo.new() a.hello() Monday, 21 January 13