Sha256: bfc9ed87d57f75a74a834089c3fd673e2fe71ae6d4c315377b10ba5711c74e72
Contents?: true
Size: 1.6 KB
Versions: 4
Compression:
Stored size: 1.6 KB
Contents
def delete update_attributes :trash => true end def delete! update_attributes! :trash => true end event :pull_from_trash, :before=>:store, :on=>:create do if trashed_card = Card.find_by_key_and_trash(key, true) # a. (Rails way) tried Card.where(:key=>'wagn_bot').select(:id), but it wouldn't work. This #select # generally breaks on cards. I think our initialization process screws with something # b. (Wagn way) we could get card directly from fetch if we add :include_trashed (eg). # likely low ROI, but would be nice to have interface to retrieve cards from trash... self.id = trashed_card.id @from_trash = true @new_record = false end self.trash = false true end event :validate_delete, :before=>:approve, :on=>:delete do if !codename.blank? errors.add :delete, "#{name} is is a system card. (#{codename})" end undeletable_all_rules_tags = %w{ default style layout create read update delete } if junction? and left.codename == 'all' and undeletable_all_rules_tags.member? right.codename errors.add :delete, "#{name} is an indestructible rule" end if account && Card::Revision.find_by_creator_id( self.id ) errors.add :delete, "Edits have been made with #{name}'s user account.\n Deleting this card would mess up our revision records." end end event :validate_delete_children, :after=>:approve, :on=>:delete do children.each do |child| subcards[child.name]=child child.trash = true unless child.valid? child.errors.each do |field, message| errors.add field, "can't delete #{child.name}: #{message}" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
wagn-1.13.0 | mod/core/set/all/trash.rb |
wagn-1.13.0.pre2 | mods/core/sets/all/trash.rb |
wagn-1.13.0.pre1 | mods/core/sets/all/trash.rb |
wagn-1.13.0.pre | mods/core/sets/all/trash.rb |