Module: Card::Set::Type::Set

Extended by:
Card::Set
Defined in:
card/tmpsets/set/mod036-card-mod-rules/type/set.rb,
card/tmpsets/set/mod025-card-mod-follow/type/set.rb,
card/tmpsets/set/mod036-card-mod-rules/type/set/html_views.rb,
card/tmpsets/set/mod036-card-mod-rules/type/set/rules_filter.rb,
card/tmpsets/set/mod036-card-mod-rules/type/set/setting_lists.rb,
card/tmpsets/set/mod036-card-mod-rules/type/set/html_views/template.rb,
card/tmpsets/set/mod036-card-mod-rules/type/set/html_views/rule_lists.rb,
card/tmpsets/set/mod037-card-mod-rules/type/set.rb,
card/tmpsets/set/mod026-card-mod-follow/type/set.rb,
card/tmpsets/set/mod037-card-mod-rules/type/set/html_views.rb,
card/tmpsets/set/mod037-card-mod-rules/type/set/rules_filter.rb,
card/tmpsets/set/mod037-card-mod-rules/type/set/setting_lists.rb,
card/tmpsets/set/mod037-card-mod-rules/type/set/html_views/template.rb,
card/tmpsets/set/mod037-card-mod-rules/type/set/html_views/rule_lists.rb

Overview

Set: All “Set” cards

Defined Under Namespace

Modules: HtmlViews, RulesFilter, SettingLists

Constant Summary

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Constants included from Event::Api

Event::Api::OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Card::Set

reset_modules

Methods included from I18nScope

#mod_name, #scope

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 AdvancedApi

#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 Basket

#abstract_basket, #add_to_basket, #basket, #unshift_basket

Methods included from Card::Set::Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



7
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 7

def self.source_location; "/Users/ethan/dev/decko/gem/card-mod-rules/set/type/set.rb"; end

Instance Method Details

#all_members_followed?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'card/tmpsets/set/mod025-card-mod-follow/type/set.rb', line 36

def all_members_followed?
  all_members_followed_by? Auth.current_id
end

#all_members_followed_by?(user_id = nil) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
44
# File 'card/tmpsets/set/mod025-card-mod-follow/type/set.rb', line 40

def all_members_followed_by? user_id=nil
  return false unless prototype.followed_by?(user_id)

  directly_followed_by?(user_id) || broader_set_followed_by?(user_id)
end

#all_user_ids_with_rule_for(setting_code) ⇒ Object



64
65
66
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 64

def all_user_ids_with_rule_for setting_code
  Card::Rule.all_user_ids_with_rule_for self, setting_code
end

#anchorObject



14
15
16
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 14

def anchor
  Card[anchor_name]
end

#anchor_nameObject



10
11
12
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 10

def anchor_name
  name.left_name
end

#broader_set_followed_by?(user_id) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
# File 'card/tmpsets/set/mod025-card-mod-follow/type/set.rb', line 46

def broader_set_followed_by? user_id
  broader_sets.find do |set_name|
    Card.fetch(set_name)&.directly_followed_by? user_id
  end
end

#broader_setsObject



91
92
93
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 91

def broader_sets
  prototype.set_names[1..-1]
end

#directly_followed?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'card/tmpsets/set/mod025-card-mod-follow/type/set.rb', line 52

def directly_followed?
  directly_followed_by? Auth.current_id
end

#directly_followed_by?(user_id = nil) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
59
60
# File 'card/tmpsets/set/mod025-card-mod-follow/type/set.rb', line 56

def directly_followed_by? user_id=nil
  return true if user_id && follow_rule?(user_id)

  follow_rule?
end

#event: cache_expired_for_new_setObject



8
9
10
# File 'card/tmpsets/set/mod025-card-mod-follow/type/set.rb', line 8

event :cache_expired_for_new_set, :store, on: :create do
  Card.follow_caches_expired
end

#follow_labelObject



16
17
18
19
20
21
22
# File 'card/tmpsets/set/mod025-card-mod-follow/type/set.rb', line 16

def follow_label
  if (klass = subclass_for_set)
    klass.short_label name.left_name
  else
    ""
  end
end

#follow_rule_name(user = nil) ⇒ Object



24
25
26
# File 'card/tmpsets/set/mod025-card-mod-follow/type/set.rb', line 24

def follow_rule_name user=nil
  Card::Name[[name, user, :follow].compact]
end

#follow_set_cardObject



32
33
34
# File 'card/tmpsets/set/mod025-card-mod-follow/type/set.rb', line 32

def follow_set_card
  self
end

#followed_by?(user_id = nil) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'card/tmpsets/set/mod025-card-mod-follow/type/set.rb', line 28

def followed_by? user_id=nil
  all_members_followed_by? user_id
end

#inheritable?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 26

def inheritable?
  junction_only? || (anchor_name&.junction? && self_set?)
end

#junction_only?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 39

def junction_only?
  @junction_only.nil? ? (@junction_only = subclass_for_set.junction_only) : @junction_only
end

#labelObject



43
44
45
46
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 43

def label
  klass = subclass_for_set
  klass ? klass.label(anchor_name) : ""
end

#list_direct_followers?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'card/tmpsets/set/mod025-card-mod-follow/type/set.rb', line 12

def list_direct_followers?
  true
end

#patternObject



22
23
24
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 22

def pattern
  tag
end

#pattern_nameObject



18
19
20
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 18

def pattern_name
  name.tag_name
end

#prototypeObject



95
96
97
98
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 95

def prototype
  opts = subclass_for_set.prototype_args anchor_name
  Card.fetch opts[:name], new: opts
end

#prototype_default_cardObject



104
105
106
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 104

def prototype_default_card
  prototype.rule_card(:default)
end

#prototype_default_type_idObject



100
101
102
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 100

def prototype_default_type_id
  prototype_default_card.type_id
end


108
109
110
111
112
113
114
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 108

def related_sets with_self=false
  if subclass_for_set.anchorless?
    prototype.related_sets with_self
  else
    left(new: {}).related_sets with_self
  end
end

#rule_cache_key_baseObject



56
57
58
59
60
61
62
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 56

def rule_cache_key_base
  if (l = left) && (r = right)
    "#{l.id}+#{Codename[r.id]}"
  else
    Codename[id].to_s
  end
end

#self_set?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 30

def self_set?
  pattern_name == Card::Set::Self.pattern.key
end

#setting_codenames_by_groupObject



68
69
70
71
72
73
74
75
76
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 68

def setting_codenames_by_group
  result = {}
  Card::Setting.groups.each do |group, settings|
    visible_settings =
      settings.reject { |s| !s || !s.applies_to_cardtype(prototype.type_id) }
    result[group] = visible_settings.map(&:codename) unless visible_settings.empty?
  end
  result
end

#subclass_for_setObject



34
35
36
37
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 34

def subclass_for_set
  current_set_pattern_code = pattern.codename
  Card.set_patterns.find { |set| set.pattern_code == current_set_pattern_code }
end

#uncapitalized_labelObject



48
49
50
51
52
53
54
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 48

def uncapitalized_label
  label = label.to_s
  return label unless label[0]

  label[0] = label[0].downcase
  label
end

#visible_setting_codenamesObject



78
79
80
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 78

def visible_setting_codenames
  @visible_setting_codenames ||= visible_settings.map(&:codename)
end

#visible_settings(group = nil, cardtype_id = nil) ⇒ Object



82
83
84
85
86
87
88
89
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set.rb', line 82

def visible_settings group=nil, cardtype_id=nil
  cardtype_id ||= prototype.type_id
  settings =
    (group && Card::Setting.groups[group]) || Card::Setting.groups.values.flatten.compact
  settings.reject do |setting|
    !setting || !setting.applies_to_cardtype(cardtype_id)
  end
end