Skip to content

Instantly share code, notes, and snippets.

@pocke
Created November 5, 2017 11:01
Show Gist options
  • Select an option

  • Save pocke/0eb21209c122def5194ada776b578559 to your computer and use it in GitHub Desktop.

Select an option

Save pocke/0eb21209c122def5194ada776b578559 to your computer and use it in GitHub Desktop.
class A
using(Module.new do
refine A do
def private_hello
puts 'Hello, real private method!'
end
end
end)
def public_hello
private_hello
end
end
A.new.public_hello # => Hello, real private method!
A.new.private_hello rescue p $! # => NoMethodError
A.new.__send__ :private_hello rescue p $! # => NoMethodError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment