Sha256: de1782cf3b471fbc8a991ba894901018e397078222d42a5351eaa2afd69ef023

Contents?: true

Size: 1.73 KB

Versions: 9

Compression:

Stored size: 1.73 KB

Contents

# -*- encoding : utf-8 -*-
class Card; module Set; class All
# Set: All cards (ListChanges)
#
# -*- encoding : utf-8 -*-
module ListChanges;
extend Card::Set
def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/standard/set/all/list_changes.rb"; end

def list_fields
  Card.search({ left: name, type_id: Card::ListID }, "list fields")
end

def listed_by_fields
  Card.search({ left: name, type_id: Card::ListedByID }, "listed by fields")
end

def linker_lists
  Card.search({ type_id: Card::ListID, link_to: name },
              "lists that link to #{name}")
end

def codename_list_exist?
  Card::Codename.exists? :list
end

event :trunk_cardtype_of_a_list_relation_changed, :finalize,
      changed: :type, on: :update,
      when: :codename_list_exist? do
  type_key_was = (tk = Card.quick_fetch(type_id_before_last_save)) && tk.key

  list_fields.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
  listed_by_fields.each &:update_cached_list
end

event :trunk_name_of_a_list_relation_changed, :finalize,
      changed: :name,  on: :update,
      when: :codename_list_exist? do
  list_fields.each do |card|
    card.update_listed_by_cache_for card.item_keys
  end
  listed_by_fields.each &:update_cached_list
end

event :cardtype_of_list_item_changed, :validate,
      changed: :type, on: :save,
      when: :codename_list_exist? do
  linker_lists.each do |card|
    next unless 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;end;end;end;
# ~~ generated from /Users/ethan/dev/decko/gem/card/mod/standard/set/all/list_changes.rb ~~

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
card-1.99.4 tmpsets/set/mod021-standard/all/list_changes.rb
card-1.99.3 tmpsets/set/mod021-standard/all/list_changes.rb
card-1.99.2 tmpsets/set/mod021-standard/all/list_changes.rb
card-1.99.1 tmpsets/set/mod021-standard/all/list_changes.rb
card-1.99.0 tmpsets/set/mod021-standard/all/list_changes.rb
card-1.98.3 tmpsets/set/mod021-standard/all/list_changes.rb
card-1.98.2 tmpsets/set/mod021-standard/all/list_changes.rb
card-1.98.1 tmpsets/set/mod021-standard/all/list_changes.rb
card-1.98.0 tmpsets/set/mod021-standard/all/list_changes.rb