Skip to content

Instantly share code, notes, and snippets.

@stevenbristol
Created August 2, 2012 12:24
Show Gist options
  • Save stevenbristol/3236666 to your computer and use it in GitHub Desktop.
Save stevenbristol/3236666 to your computer and use it in GitHub Desktop.
Using extend and include
module Logger
def log str
p str
end
end
class Thing3
include Logger
extend Logger
log "this does work from class" # => "this does work from class"
def test_log
log "this does work from instance"
Thing3.log "this does work from class (via class in instance)"
end
end
Thing3.new.test_log # => "this does work from instance"
# => "this does work from class (via class in instance)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment