Module.class_eval do def dup_including(*methods) dup.class_eval do aliased = (methods.last.is_a? Hash) ? methods.last : {} aliased.each{ |from, to| alias_method to, from } to_be_kept_methods = methods + aliased.values (all_instance_methods - to_be_kept_methods).each{ |m| remove_method m } self end end def all_instance_methods private_methods = (respond_to? :private_instance_methods) ? private_instance_methods : [] instance_methods + private_methods end if const_defined? :MRUBY_VERSION alias_method :simple_const_get, :const_get def const_get(constant_path, *args) if constant_path.is_a? String constant_path.split('::').inject(self) do |mod, constant| mod.simple_const_get(constant.to_sym, *args) end else simple_const_get(constant_path, *args) end end end end