Sha256: 2226ac66c896e7d574f5ba5df2d991dbf32ab8f789a948a59285c9e737279c1c
Contents?: true
Size: 1.39 KB
Versions: 6
Compression:
Stored size: 1.39 KB
Contents
# -*- encoding : utf-8 -*- event :trunk_cardtype_of_a_list_relation_changed, changed: :type, after: :store, on: :update, when: proc { Codename[:list] } do type_key_was = (tk = Card.fetch(type_id_was)) && tk.key if (list_cards = Card.search(left: name, type_id: Card::ListID)) list_cards.each do |card| card.update_listed_by_cache_for card.item_keys, type_key: type_key_was card.update_listed_by_cache_for card.item_keys end end if (listed_by_cards = Card.search(left: name, type_id: Card::ListedByID)) listed_by_cards.each(&:update_cached_list) end end event :trunk_name_of_a_list_relation_changed, changed: :name, after: :store, on: :update, when: proc { Codename[:list] } do if (list_cards = Card.search(left: name, type_id: Card::ListID)) list_cards.each do |card| card.update_listed_by_cache_for card.item_keys end end if (listed_by_cards = Card.search(left: name, type_id: Card::ListedByID)) listed_by_cards.each(&:update_cached_list) end end event :cardtype_of_list_item_changed, changed: :type, before: :approve, on: :save, when: proc { Codename[:list] } do Card.search(type_id: Card::ListID, link_to: name).each do |card| if card.item_type_id != type_id errors.add( :type, "can't be changed because #{name} " \ "is referenced by list card #{card.name}" ) end end end
Version data entries
6 entries across 6 versions & 1 rubygems