Module: Card::Set::All::Follow::FollowedBy
- Extended by:
- Card::Set
- Defined in:
- platypus/tmp/set/gem-defaults/mod028-follow/all/follow/followed_by.rb
Overview
Set: All cards (Follow, FollowedBy)
used by +:followers overwritten in type/set.rb and type/cardtype.rb
Constant Summary
Constants included from Helpers
Helpers::SET_PATTERN_TEST_REGEXP
Constants included from Event::Api
Class Method Summary collapse
Instance Method Summary collapse
-
#all_follow_rule_options(follower_id) ⇒ Object
-
#follow_rule_applies?(follower_id) ⇒ Boolean
the following methods all handle explicit (direct) follow rules (not fields).
-
#follow_rule_option(follower_id) ⇒ Object
-
#follow_rule_option_applies?(follower_id, option) ⇒ Boolean
-
#follow_rule_option_applies_to_candidates?(follower_id, option_code, candidate_ids) ⇒ Boolean
-
#followed? ⇒ Boolean
-
#followed_by?(user_id) ⇒ Boolean
for sets and cardtypes it doesn’t check whether the users is following the card itself instead it checks whether he is following the complete set.
-
#followed_by_as_field?(field, user_id) ⇒ Boolean
-
#followed_field?(field_card) ⇒ Boolean
returns true if according to the follow_field_rule followers of self also follow changes of field_card.
-
#follower_candidate_ids_for_option(option_code) ⇒ Object
-
#nested_card?(card) ⇒ Boolean
Methods included from Card::Set
Methods included from I18nScope
Methods included from Registrar
#extended, #finalize_load, #process_base_modules, #register_set
Methods included from Helpers
#format_module, #format_modules, #method_missing, #modules, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscored_name
Methods included from Card::Set::AdvancedApi
#assign_type, #attachment, #define_set_from_error, #ensure_set, #setting_opts, #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 Trait
#card_accessor, #card_reader, #card_writer, #require_field
Methods included from Event::Api
Class Method Details
.source_location ⇒ Object
8 |
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/follow/followed_by.rb', line 8 def self.source_location; "/Users/ethan/dev/decko/gem/mod/follow/set/all/follow/followed_by.rb"; end |
Instance Method Details
#all_follow_rule_options(follower_id) ⇒ Object
52 53 54 55 56 57 |
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/follow/followed_by.rb', line 52 def follower_id follow_rule = preference :follow, follower_id return [] unless follow_rule.present? follow_rule.split("\n") end |
#follow_rule_applies?(follower_id) ⇒ Boolean
the following methods all handle explicit (direct) follow rules (not fields)
42 43 44 |
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/follow/followed_by.rb', line 42 def follow_rule_applies? follower_id !follow_rule_option(follower_id).nil? end |
#follow_rule_option(follower_id) ⇒ Object
46 47 48 49 50 |
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/follow/followed_by.rb', line 46 def follow_rule_option follower_id (follower_id).find do |option| follow_rule_option_applies? follower_id, option end end |
#follow_rule_option_applies?(follower_id, option) ⇒ Boolean
59 60 61 62 63 |
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/follow/followed_by.rb', line 59 def follow_rule_option_applies? follower_id, option option_code = option.to_name.codename candidate_ids = follower_candidate_ids_for_option option_code follow_rule_option_applies_to_candidates? follower_id, option_code, candidate_ids end |
#follow_rule_option_applies_to_candidates?(follower_id, option_code, candidate_ids) ⇒ Boolean
65 66 67 68 69 70 71 |
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/follow/followed_by.rb', line 65 def follow_rule_option_applies_to_candidates? follower_id, option_code, candidate_ids if (test = FollowOption.test[option_code]) test.call follower_id, candidate_ids else candidate_ids.include? follower_id end end |
#followed? ⇒ Boolean
9 10 11 |
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/follow/followed_by.rb', line 9 def followed? followed_by? Auth.current_id end |
#followed_by?(user_id) ⇒ Boolean
for sets and cardtypes it doesn’t check whether the users is following the card itself instead it checks whether he is following the complete set
15 16 17 |
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/follow/followed_by.rb', line 15 def followed_by? user_id follow_rule_applies?(user_id) || left&.followed_by_as_field?(self, user_id) end |
#followed_by_as_field?(field, user_id) ⇒ Boolean
19 20 21 |
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/follow/followed_by.rb', line 19 def followed_by_as_field? field, user_id followed_field?(field) && followed_by?(user_id) end |
#followed_field?(field_card) ⇒ Boolean
returns true if according to the follow_field_rule followers of self also follow changes of field_card
25 26 27 28 29 30 31 32 33 34 |
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/follow/followed_by.rb', line 25 def followed_field? field_card return unless (follow_field_rule = rule_card(:follow_fields)) follow_field_rule.item_names(context: self).find do |item| case item.to_name.key when field_card.key then true when :nests.cardname.key then nested_card?(field_card) end end end |
#follower_candidate_ids_for_option(option_code) ⇒ Object
73 74 75 76 77 |
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/follow/followed_by.rb', line 73 def follower_candidate_ids_for_option option_code return [] unless (block = FollowOption.follower_candidate_ids[option_code]) block.call self end |
#nested_card?(card) ⇒ Boolean
36 37 38 |
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/follow/followed_by.rb', line 36 def nested_card? card nestee_ids.include? card.id end |