Skip to content

Instantly share code, notes, and snippets.

@takkkun
Created April 4, 2014 08:38
Show Gist options
  • Save takkkun/9970603 to your computer and use it in GitHub Desktop.
Save takkkun/9970603 to your computer and use it in GitHub Desktop.
module Submodule
def subset(&pred)
mod = self
Module.new do
include mod
public_instance_methods.each do |method_name|
method = instance_method(method_name)
undef_method method_name unless pred.call(method)
end
end
end
end
Module.__send__(:include, Submodule)
p Kernel.instance_methods
p Kernel.subset { |method| method.name =~ /^define_singleton_/ }.instance_methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment