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 )
end
def destroy
delete
Card.save_all
end
def delete(reindex = true)
Card.delete( self.id )
super()
section.reset_index if reindex
end

View File

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

View File

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

View File

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