Skip to content

Instantly share code, notes, and snippets.

@TheNotary
Created November 8, 2021 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheNotary/999a52a0830360350cf5c2f9213d3ab9 to your computer and use it in GitHub Desktop.
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?
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