Skip to content

Instantly share code, notes, and snippets.

@tomafro
Created February 15, 2018 08:30
Show Gist options
  • Save tomafro/054d7d1a7c40ade27405599289196a54 to your computer and use it in GitHub Desktop.
Save tomafro/054d7d1a7c40ade27405599289196a54 to your computer and use it in GitHub Desktop.
Suppressible
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