Module: Card::Set::Type::Set
- Extended by:
- Card::Set
- Defined in:
- platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb,
platypus/tmp/set/gem-defaults/mod028-follow/type/set.rb,
platypus/tmp/set/gem-defaults/mod010-rules/type/set/html_views.rb,
platypus/tmp/set/gem-defaults/mod010-rules/type/set/setting_categories.rb,
platypus/tmp/set/gem-defaults/mod010-rules/type/set/html_views/template.rb,
platypus/tmp/set/gem-defaults/mod010-rules/type/set/html_views/rule_lists.rb,
platypus/tmp/set/gem-defaults/mod010-rules/type/set/html_views/setting_filter.rb,
platypus/tmp/set/gem-defaults/mod010-rules/type/set/html_views/filtered_rule_lists.rb
Overview
Defined Under Namespace
Modules: HtmlViews, SettingCategories
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
Methods included from I18nScope
#mod_name, #scope
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
#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
#include_set, #include_set_formats
#card_accessor, #card_reader, #card_writer, #require_field
Methods included from Event::Api
#event
Class Method Details
.source_location ⇒ Object
7
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 7
def self.source_location; "/Users/ethan/dev/decko/gem/mod/rules/set/type/set.rb"; end
|
Instance Method Details
#all_members_followed? ⇒ Boolean
36
37
38
|
# File 'platypus/tmp/set/gem-defaults/mod028-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
40
41
42
43
44
|
# File 'platypus/tmp/set/gem-defaults/mod028-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
66
67
68
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 66
def all_user_ids_with_rule_for setting_code
Card::Rule.all_user_ids_with_rule_for self, setting_code
end
|
16
17
18
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 16
def anchor
Card[anchor_name]
end
|
#anchor_name ⇒ Object
12
13
14
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 12
def anchor_name
name.left_name
end
|
#broader_set_followed_by?(user_id) ⇒ Boolean
46
47
48
49
50
|
# File 'platypus/tmp/set/gem-defaults/mod028-follow/type/set.rb', line 46
def broader_set_followed_by? user_id
broader_sets.find do |set_card|
set_card&.directly_followed_by? user_id
end
end
|
#broader_sets ⇒ Object
93
94
95
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 93
def broader_sets
prototype.set_names[1..-1].map(&Card.method(:fetch))
end
|
#compound_only? ⇒ Boolean
41
42
43
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 41
def compound_only?
@compound_only.nil? ? (@compound_only = subclass_for_set.compound_only) : @compound_only
end
|
#directly_followed? ⇒ Boolean
52
53
54
|
# File 'platypus/tmp/set/gem-defaults/mod028-follow/type/set.rb', line 52
def directly_followed?
directly_followed_by? Auth.current_id
end
|
#directly_followed_by?(user_id = nil) ⇒ Boolean
56
57
58
59
60
|
# File 'platypus/tmp/set/gem-defaults/mod028-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_set ⇒ Object
8
9
10
|
# File 'platypus/tmp/set/gem-defaults/mod028-follow/type/set.rb', line 8
event :cache_expired_for_new_set, :store, on: :create do
Card.follow_caches_expired
end
|
#follow_label ⇒ Object
16
17
18
19
20
21
22
|
# File 'platypus/tmp/set/gem-defaults/mod028-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 'platypus/tmp/set/gem-defaults/mod028-follow/type/set.rb', line 24
def follow_rule_name user=nil
Card::Name[[name, user, :follow].compact]
end
|
#follow_set_card ⇒ Object
32
33
34
|
# File 'platypus/tmp/set/gem-defaults/mod028-follow/type/set.rb', line 32
def follow_set_card
self
end
|
#followed_by?(user_id = nil) ⇒ Boolean
28
29
30
|
# File 'platypus/tmp/set/gem-defaults/mod028-follow/type/set.rb', line 28
def followed_by? user_id=nil
all_members_followed_by? user_id
end
|
#inheritable? ⇒ Boolean
28
29
30
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 28
def inheritable?
compound_only? || (anchor_name&.compound? && self_set?)
end
|
45
46
47
48
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 45
def label
klass = subclass_for_set
klass ? klass.label(anchor_name) : ""
end
|
#label_and_url_key ⇒ Object
118
119
120
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 118
def label_and_url_key
[label, name.to_name.url_key]
end
|
#list_direct_followers? ⇒ Boolean
12
13
14
|
# File 'platypus/tmp/set/gem-defaults/mod028-follow/type/set.rb', line 12
def list_direct_followers?
true
end
|
24
25
26
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 24
def pattern
tag
end
|
#pattern_name ⇒ Object
20
21
22
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 20
def pattern_name
name.tag_name
end
|
#prototype ⇒ Object
97
98
99
100
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 97
def prototype
opts = subclass_for_set.prototype_args anchor_name
Card.fetch opts[:name], new: opts
end
|
#prototype_default_card ⇒ Object
106
107
108
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 106
def prototype_default_card
prototype.rule_card(:default)
end
|
#prototype_default_type_id ⇒ Object
102
103
104
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 102
def prototype_default_type_id
prototype_default_card.type_id
end
|
110
111
112
113
114
115
116
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 110
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_base ⇒ Object
58
59
60
61
62
63
64
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 58
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
32
33
34
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 32
def self_set?
pattern_name == Card::Set::Self.pattern.key
end
|
#setting_codenames_by_group ⇒ Object
70
71
72
73
74
75
76
77
78
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 70
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_set ⇒ Object
36
37
38
39
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 36
def subclass_for_set
current_set_pattern_code = pattern.codename
Pattern.concrete.find { |set| set.pattern_code == current_set_pattern_code }
end
|
#uncapitalized_label ⇒ Object
50
51
52
53
54
55
56
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 50
def uncapitalized_label
label = label.to_s
return label unless label[0]
label[0] = label[0].downcase
label
end
|
#visible_setting_codenames ⇒ Object
80
81
82
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 80
def visible_setting_codenames
@visible_setting_codenames ||= visible_settings.map(&:codename)
end
|
#visible_settings(group = nil, cardtype_id = nil) ⇒ Object
84
85
86
87
88
89
90
91
|
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set.rb', line 84
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
|