Module: Trashable

Extended by:
ActiveSupport::Concern
Included in:
Invite, Post, PostAction, Topic, TopicEmbed, TopicTimer
Defined in:
app/models/concerns/trashable.rb

Instance Method Summary collapse

Instance Method Details

#recover!Object



28
29
30
# File 'app/models/concerns/trashable.rb', line 28

def recover!
  trash_update(nil, nil)
end

#trash!(trashed_by = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'app/models/concerns/trashable.rb', line 18

def trash!(trashed_by = nil)
  # note, an argument could be made that the column should probably called trashed_at
  # however, deleted_at is the terminology used in the UI
  #
  # we could hijack use a delete! and delete - redirecting the originals elsewhere, but that is
  # confusing as well. So for now, we go with trash!
  #
  trash_update(DateTime.now, trashed_by.try(:id))
end

#trashed?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/models/concerns/trashable.rb', line 14

def trashed?
  deleted_at.present?
end