-
-
Save 0x1eef/b834293c83d7928acb36b23e13d0b774 to your computer and use it in GitHub Desktop.
This file contains 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
class MyClass | |
def initialize; end | |
def log(level, msg) | |
puts "#{level}: #{msg}" | |
end | |
[:debug, :info].each do |m| | |
define_method(m) do |msg| | |
log(__method__, msg) | |
end | |
end | |
# same code for warn, error, fatal, unknown | |
end | |
MyClass.new.debug "foo" | |
MyClass.new.info "bar" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment