-
-
Save tomafro/054d7d1a7c40ade27405599289196a54 to your computer and use it in GitHub Desktop.
Suppressible
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
module Suppressible | |
def self.extended(base) | |
base.thread_mattr_accessor :suppressed, instance_accessor: false | |
base.delegate :suppressed?, to: 'self.class' | |
end | |
def suppress(&block) | |
original, self.suppressed = self.suppressed, true | |
yield | |
ensure | |
self.suppressed = original | |
end | |
def suppressed? | |
suppressed | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment