Module: Card::Set::Right::Read
- Extended by:
- Card::Set
- Includes:
- Abstract::Permission
- Defined in:
- tmpsets/set/mod015-settings/right/read.rb
Overview
Set: All "+Read" cards
Class Method Summary collapse
Instance Method Summary collapse
- #reset_patterns_if_rule(saving = false) ⇒ Object
-
#update_read_ruled_cards(set) ⇒ Object
TODO: the following really needs a refactor.
- #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, #underscore
Methods included from AdvancedApi
#attachment, #ensure_set, #stage_method
Methods included from Format
#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name
Methods included from Inheritance
#include_set, #include_set_formats
Methods included from Basket
#abstract_basket, #add_to_basket, #basket, #unshift_basket
Methods included from Trait
#card_accessor, #card_reader, #card_writer, #require_field
Methods included from Event::Api
Methods included from Abstract::Permission
Class Method Details
.source_location ⇒ Object
7 |
# File 'tmpsets/set/mod015-settings/right/read.rb', line 7 def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/settings/set/right/read.rb"; end |
Instance Method Details
#reset_patterns_if_rule(saving = false) ⇒ Object
19 20 21 22 |
# File 'tmpsets/set/mod015-settings/right/read.rb', line 19 def reset_patterns_if_rule saving=false return unless (set = super) add_to_read_rule_update_queue set.item_cards(limit: 0) if saving end |
#update_read_ruled_cards(set) ⇒ Object
TODO: the following really needs a refactor.
It was written (long ago) to handle different kinds of changes, but this could be significantly simplified with smarter events.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'tmpsets/set/mod015-settings/right/read.rb', line 29 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
47 48 49 50 51 52 53 54 55 |
# File 'tmpsets/set/mod015-settings/right/read.rb', line 47 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
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'tmpsets/set/mod015-settings/right/read.rb', line 62 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 |