Class: Effective::Trash

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/effective/trash.rb

Instance Method Summary collapse

Instance Method Details

#detailsObject



25
26
27
# File 'app/models/effective/trash.rb', line 25

def details
  self[:details] || {}
end

#restore_trash!Object

So this is a Trash item When we delete ourselves, we restore this trash item first



31
32
33
34
# File 'app/models/effective/trash.rb', line 31

def restore_trash!
  raise 'no attributes to restore from' unless details.kind_of?(Hash) && details[:attributes].present?
  trashed_type.constantize.new(details[:attributes]).save!
end

#to_sObject



21
22
23
# File 'app/models/effective/trash.rb', line 21

def to_s
  [trashed_type, trashed_id].join(' ').presence || 'New Trash item'
end