Skip to content

Instantly share code, notes, and snippets.

Created May 23, 2014 23:49
Show Gist options
  • Save anonymous/dfbf0572175f07e01e13 to your computer and use it in GitHub Desktop.
Save anonymous/dfbf0572175f07e01e13 to your computer and use it in GitHub Desktop.
module Barkable
def bark!
puts "Bark! I'm #{state}!!"
end
def state
["happy", "sad", "melancholy"][rand(3)]
end
end
class Dog
include Barkable
def initialize
bark!
# I don't want/need Barkable::state() to be available from this point.
# I might want to use that method name for something more appropriate
# to the "Dog" class, and I don't want to deal with collisions.
# What's best practice for methods I only need to access from within
# a module?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment