Created
November 8, 2021 22:53
-
-
Save TheNotary/999a52a0830360350cf5c2f9213d3ab9 to your computer and use it in GitHub Desktop.
What's the best way to add putsd as an alternative to puts to an app?
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 App | |
module Debugable | |
def putsd(msg) | |
puts msg if ENV[DEBUG] | |
end | |
def self.putsd(msg) | |
puts msg if ENV[DEBUG] | |
end | |
end | |
end | |
module App | |
class Glass | |
extend Debugable | |
include Debugable | |
def drink | |
putsd "Glass is being drinked from!" | |
end | |
end | |
end | |
module App | |
extend Debugable | |
include Debugable | |
DEBUG = "PARAMETER_DEBUG" | |
def self.main | |
putsd "Initializing with no parameters" | |
glass = Glass.new | |
glass.drink | |
end | |
end | |
ENV['PARAMETER_DEBUG'] = 'true' | |
App.main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment