Skip to content

Instantly share code, notes, and snippets.

@mark
Created November 13, 2014 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mark/d28947ccac284649d673 to your computer and use it in GitHub Desktop.
Save mark/d28947ccac284649d673 to your computer and use it in GitHub Desktop.
Marks-MacBook-Pro:code_scraps markjosef$ irb
irb(main):001:0> require './private_clobbering'
=> true
irb(main):002:0> obj = MyClass.new
=> #<MyClass:0x007ff8220fc680>
irb(main):003:0> obj.public_a
Public A
Private B
=> nil
irb(main):004:0> obj.public_b
Public B
Private B
=> nil
irb(main):005:0> obj.my_public_method
Public C
Private B
=> nil
module ModuleA
def public_a
puts "Public A"
my_private_method
end
private
def my_private_method
puts "Private A"
end
end
module ModuleB
def public_b
puts "Public B"
my_private_method
end
private
def my_private_method
puts "Private B"
end
end
class MyClass
include ModuleA
include ModuleB
def my_public_method
puts "Public C"
my_private_method
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment