Skip to content

Instantly share code, notes, and snippets.

@rreinhardt9
Created July 15, 2022 17:51
Show Gist options
  • Save rreinhardt9/1f7259d5a4d8d359457ecfa1e9a20fc8 to your computer and use it in GitHub Desktop.
Save rreinhardt9/1f7259d5a4d8d359457ecfa1e9a20fc8 to your computer and use it in GitHub Desktop.
Re-creating the "Suppressible" concern that was shown in this screencast from DHH: https://www.youtube.com/watch?v=m1jOWu7woKM
module Suppressible
extend ActiveSupport::Concern
class_methods do
def suppress
self.suppressed = true
yield
ensure
self.suppressed = false
end
def suppressed?
suppressed == true
end
private
attr_accessor :suppressed
end
end
@bartimez
Copy link

Hmm, maybe the answer there is unless hooks on the specific callbacks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment