Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module ActiveRecord
- module Suppressor
- extend ActiveSupport::Concern
- module ClassMethods
- def suppress(&block)
- SuppressorRegistry.suppressed[name] = true
- yield
- ensure
- SuppressorRegistry.suppressed[name] = false
- end
- end
- # Ignore saving events if we're in suppression mode.
- def save!(*args)
- SuppressorRegistry.suppressed[self.class.name] ? self : super
- end
- end
- class SuppressorRegistry # :nodoc:
- extend ActiveSupport::PerThreadRegistry
- attr_reader :suppressed
- def initialize
- @suppressed = {}
- end
- end
- end
- module ActiveRecord
- class Base
- #Other Modules
- #..
- #..
- #..
- include Suppressor
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement