# module name is a constant
module Debug
# constant will not be mixin
LEVEL = 'error'
# instance variable.
# It may clash with those of the host class or with those of other mixins.
# For the most part, mixin doesn't use instance variables directly, they use accessors of hosts.
attr_accessor :message
# instance method
def whois
#{self.class.name}"
end
end
class Apple
# mixin a module use `include`
include Debug
end
apple = Apple.new
# access mixin method
p apple.whois #=> Apple
# access mixin instance variable
# Again, a module has its own state is not a mixin, it should be written as a class.
apple.message = 'Google'
p apple.message #=> Apple