Module: Card::Set::All::UpdateReadRules
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod002-core/all/update_read_rules.rb
Constant Summary
Constants included from Format
Instance Method Summary collapse
- #id_of_set_class(set) ⇒ Object
- #update_read_ruled_cards(set) ⇒ Object
- #update_read_rules_not_overridden_by_narrower_rules(cur_index, rule_class_index, set) ⇒ Object
- #update_read_rules_of_set_members(set) ⇒ Object
Methods included from I18nScope
Methods included from Loader
#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set
Methods included from Helpers
#abstract_set?, #all_set?, #num_set_parts, #shortname
Methods included from Card::Set::AdvancedApi
#attachment, #ensure_set, #stage_method
Methods included from Format
#all_set_format_mod!, #define_on_format, #format, #register_set_format, #view
Methods included from Inheritance
#include_set, #include_set_formats
Methods included from Basket
#abstract_basket, #add_to_basket, #basket
Methods included from Trait
#card_accessor, #card_reader, #card_writer
Methods included from Event
Instance Method Details
#id_of_set_class(set) ⇒ Object
44 45 46 |
# File 'tmpsets/set/mod002-core/all/update_read_rules.rb', line 44 def id_of_set_class set set && (set_class = set.tag) && set_class.id end |
#update_read_ruled_cards(set) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'tmpsets/set/mod002-core/all/update_read_rules.rb', line 48 def update_read_ruled_cards set self.class.clear_read_rule_cache Card.cache.reset # maybe be more surgical, just Auth.user related expire # probably shouldn't be necessary, # but was sometimes getting cached version when card should be in the # trash. could be related to other bugs? updated = update_read_rules_of_set_members set # then find all cards with me as read_rule_id that were not just updated # and regenerate their read_rules return if new_card? Card.search(read_rule_id: id) do |card| card.update_read_rule unless updated.include?(card.key) end end |
#update_read_rules_not_overridden_by_narrower_rules(cur_index, rule_class_index, set) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'tmpsets/set/mod002-core/all/update_read_rules.rb', line 20 def update_read_rules_not_overridden_by_narrower_rules cur_index, rule_class_index, set set.item_cards(limit: 0).each_with_object(::Set.new) do |item_card, in_set| in_set << item_card.key next if cur_index < rule_class_index item_card.update_read_rule end end |
#update_read_rules_of_set_members(set) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'tmpsets/set/mod002-core/all/update_read_rules.rb', line 29 def update_read_rules_of_set_members set return ::Set.new if trash || !(class_id = id_of_set_class(set)) rule_class_ids = set_patterns.map(&:pattern_id) Auth.as_bot do if (rule_class_index = rule_class_ids.index(class_id)) cur_index = rule_class_ids.index Card[read_rule_class].id update_read_rules_not_overridden_by_narrower_rules cur_index, rule_class_index, set else warn "No current rule index #{class_id}, #{rule_class_ids.inspect}" ::Set.new end end end |