module FooModule
def self.included base
base.extend ClassMethods
end
module ClassMethods
def bar
puts "module"
end
end
end
module Klass
include FooModule
def self.bar
puts 'class'
super
end
end
Klass.bar #=> class
原文: http://tech.tulentsev.com/2012/02/ruby-how-to-override-class-method-with-a-module/