Created
November 22, 2015 10:02
-
-
Save ttanimichi/6a8bd8f18364f2f39a8c to your computer and use it in GitHub Desktop.
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
| require 'singleton' | |
| class MyLogger | |
| include Singleton | |
| def initialize | |
| @logger = $stdout | |
| end | |
| def write(msg) | |
| @logger.puts msg | |
| end | |
| end | |
| MyLogger.instance.write('hoge') | |
| module MyLogger2 | |
| class << self | |
| def write(msg) | |
| logger.puts msg | |
| end | |
| def logger | |
| @logger ||= $stdout | |
| end | |
| end | |
| end | |
| MyLogger2.write 'foo' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment