move some delete and destroy to base

This commit is contained in:
Torsten 2022-12-22 17:18:28 +02:00
parent fc611ce5c4
commit 034d605d78
4 changed files with 12 additions and 16 deletions

View File

@ -33,13 +33,8 @@ module Merged
CardStyle.find_by_template( self.template ) CardStyle.find_by_template( self.template )
end end
def destroy
delete
Card.save_all
end
def delete(reindex = true) def delete(reindex = true)
Card.delete( self.id ) super()
section.reset_index if reindex section.reset_index if reindex
end end

View File

@ -43,13 +43,8 @@ module Merged
end end
def destroy def destroy
delete
File.delete self.full_filename File.delete self.full_filename
Image.save_all super
end
def delete
Image.delete( self.id )
end end
def asset_name def asset_name

View File

@ -56,7 +56,7 @@ module Merged
has_sections = sections.length has_sections = sections.length
has_cards = 0 has_cards = 0
sections.each {|section| has_cards += section.delete(false) } sections.each {|section| has_cards += section.delete(false) }
Page.delete( self.id ) super
[has_sections , has_cards] [has_sections , has_cards]
end end

View File

@ -8,6 +8,15 @@ module ActiveYaml
self.class.save_all self.class.save_all
end end
def delete
self.class.delete(self.id)
end
def destroy
delete
self.class.save_all
end
def self.save_all def self.save_all
data = @records.collect {|obj| obj.attributes} data = @records.collect {|obj| obj.attributes}
File.write( self.full_path , data.to_yaml) File.write( self.full_path , data.to_yaml)
@ -20,8 +29,5 @@ module ActiveYaml
true true
end end
def self.the_private_records
@records
end
end end
end end