Module: Card::Set::All::Follow::FollowerIds
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod017-follow/all/follow/follower_ids.rb
Overview
Set: All cards (Follow, FollowerIds)
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- FOLLOWER_IDS_CACHE_KEY =
"FOLLOWER_IDS".freeze
Constants included from Helpers
Helpers::SET_PATTERN_TEST_REGEXP
Class Method Summary collapse
Instance Method Summary collapse
- #direct_follower_ids(&block) ⇒ Object
- #direct_follower_ids_for_set(set_card, ids) ⇒ Object
-
#direct_followers ⇒ Object
all users (cards) that "directly" follow this card "direct" means there is a follow rule that applies explicitly to this card.
- #each_direct_follower_id_with_reason ⇒ Object
- #follower_ids ⇒ Object
- #follower_names ⇒ Object
- #followers ⇒ Object
- #followers_count ⇒ Object
- #indirect_follower_ids ⇒ Object
- #read_follower_ids_cache ⇒ Object
- #setcard_from_name(set_name) ⇒ Object
- #write_follower_ids_cache(user_ids) ⇒ Object
Methods included from Card::Set
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
#method_missing, #num_set_parts, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscore
Methods included from Card::Set::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
Class Method Details
.source_location ⇒ Object
7 |
# File 'tmpsets/set/mod017-follow/all/follow/follower_ids.rb', line 7 def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/follow/set/all/follow/follower_ids.rb"; end |
Instance Method Details
#direct_follower_ids(&block) ⇒ Object
90 91 92 93 94 95 96 |
# File 'tmpsets/set/mod017-follow/all/follow/follower_ids.rb', line 90 def direct_follower_ids &block ids = ::Set.new set_names.each do |set_name| direct_follower_ids_for_set setcard_from_name(set_name), ids, &block end ids end |
#direct_follower_ids_for_set(set_card, ids) ⇒ Object
102 103 104 105 106 107 108 109 |
# File 'tmpsets/set/mod017-follow/all/follow/follower_ids.rb', line 102 def direct_follower_ids_for_set set_card, ids set_card.all_user_ids_with_rule_for(:follow).each do |user_id| next if ids.include?(user_id) || !(option = follow_rule_option user_id) yield user_id, set_card, option if block_given? ids << user_id end end |
#direct_followers ⇒ Object
all users (cards) that "directly" follow this card "direct" means there is a follow rule that applies explicitly to this card. one can also "indirectly" follow cards by following parent cards or other cards that nest this one.
84 85 86 87 88 |
# File 'tmpsets/set/mod017-follow/all/follow/follower_ids.rb', line 84 def direct_followers direct_follower_ids.map do |id| Card.fetch(id) end end |
#each_direct_follower_id_with_reason ⇒ Object
111 112 113 114 115 116 |
# File 'tmpsets/set/mod017-follow/all/follow/follower_ids.rb', line 111 def each_direct_follower_id_with_reason direct_follower_ids do |user_id, set_card, follow_option| reason = follow_option.gsub(/[\[\]]/, "") yield user_id, set_card: set_card, option: reason end end |
#follower_ids ⇒ Object
58 59 60 61 62 63 64 |
# File 'tmpsets/set/mod017-follow/all/follow/follower_ids.rb', line 58 def follower_ids @follower_ids = read_follower_ids_cache || begin result = direct_follower_ids + indirect_follower_ids write_follower_ids_cache result result end end |
#follower_names ⇒ Object
48 49 50 |
# File 'tmpsets/set/mod017-follow/all/follow/follower_ids.rb', line 48 def follower_names followers.map(&:name) end |
#followers ⇒ Object
52 53 54 55 56 |
# File 'tmpsets/set/mod017-follow/all/follow/follower_ids.rb', line 52 def followers follower_ids.map do |id| Card.fetch(id) end end |
#followers_count ⇒ Object
66 67 68 |
# File 'tmpsets/set/mod017-follow/all/follow/follower_ids.rb', line 66 def followers_count follower_ids.size end |
#indirect_follower_ids ⇒ Object
70 71 72 73 74 75 76 77 78 |
# File 'tmpsets/set/mod017-follow/all/follow/follower_ids.rb', line 70 def indirect_follower_ids result = ::Set.new left_card = left while left_card result += left_card.direct_follower_ids if left_card.followed_field? self left_card = left_card.left end result end |
#read_follower_ids_cache ⇒ Object
44 45 46 |
# File 'tmpsets/set/mod017-follow/all/follow/follower_ids.rb', line 44 def read_follower_ids_cache Card.follower_ids_cache[id] end |