Sha256: 24d0c9d9ad5ff99ff6322e2a5e9257a61b135fffdb8b1dfb8e99324967a1ffb8
Contents?: true
Size: 807 Bytes
Versions: 77
Compression:
Stored size: 807 Bytes
Contents
# The disposable module is a soft-delete helper that: # # * adds `disable!` method that set a `disabled_at` attribute and then _buries_ the object # * adds a `bury!` hook method that allows further modification when disabling # * aliases `destroy!` and `destroy` to `disable!`, but still keeps `delete` and friends # module Disabling extend ActiveSupport::Concern def disable! transaction do update_attribute :disabled_at, Time.current bury! end end def disabled? disabled_at.present? end def enabled? !disabled? end # override to perform additional # post-disable actions def bury! end def ensure_enabled! raise Mumuki::Domain::DisabledError if disabled? end alias_method :destroy!, :disable! alias_method :destroy, :disable! end
Version data entries
77 entries across 77 versions & 2 rubygems