Skip to content

Instantly share code, notes, and snippets.

@nagachika
Created January 26, 2012 04:33
Show Gist options
  • Save nagachika/1681013 to your computer and use it in GitHub Desktop.
Save nagachika/1681013 to your computer and use it in GitHub Desktop.
godscope
# `publish' all private instance methods
ObjectSpace.each_object(Module) do |mod|
mod.private_instance_methods(false).each do |meth|
mod.__send__(:public, meth)
end
end
# define accessor methods as ghost method
class Object
def method_missing(meth, *args)
if /^(.+)=$/ =~ meth.to_s and args.size == 1
name = $1.to_sym
elsif args.empty?
name = meth
else
return super
end
if self.instance_variable_defined?("@#{name}")
if meth == name
self.instance_variable_get("@#{name}")
else
self.instance_variable_set("@#{name}", args[0])
end
else
super
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment