Last active
June 30, 2025 17:27
-
-
Save havenwood/d97fa99fa19e0a3ea669c6cc304762e4 to your computer and use it in GitHub Desktop.
Mixin example for #ruby IRC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Document | |
def self.included(base) | |
base.class_eval do | |
def self.name = "#{super}ument" | |
end | |
end | |
module_function | |
def print = :printed | |
end | |
class Book | |
include Document | |
def publish = true && print | |
end | |
Book.new.publish | |
#=> :printed | |
Book.new.print | |
#!> private method 'print' called for an instance of Bookument (NoMethodError) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compare with