Module: Card::Set::Type::Set
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod022-rules/type/set.rb,
tmpsets/set/mod017-follow/type/set.rb,
tmpsets/set/mod022-rules/type/set/html_views.rb,
tmpsets/set/mod022-rules/type/set/rules_filter.rb,
tmpsets/set/mod022-rules/type/set/setting_lists.rb,
tmpsets/set/mod022-rules/type/set/html_views/template.rb,
tmpsets/set/mod022-rules/type/set/html_views/nest_rules.rb,
tmpsets/set/mod022-rules/type/set/html_views/rules_bridge.rb
Overview
Defined Under Namespace
Modules: HtmlViews, RulesFilter, SettingLists
Class Method Summary
collapse
Instance Method Summary
collapse
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
#abstract_set?, #all_set?, #num_set_parts, #shortname, #underscore
#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
#include_set, #include_set_formats
Methods included from Basket
#abstract_basket, #add_to_basket, #basket, #unshift_basket
#card_accessor, #card_reader, #card_writer, #require_field
Methods included from Event::Api
#event
Class Method Details
.source_location ⇒ Object
7
|
# File 'tmpsets/set/mod022-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
36
37
38
|
# File 'tmpsets/set/mod017-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 'tmpsets/set/mod017-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
48
49
50
|
# File 'tmpsets/set/mod022-rules/type/set.rb', line 48
def all_user_ids_with_rule_for setting_code
Card.all_user_ids_with_rule_for self, setting_code
end
|
#broader_set_followed_by?(user_id) ⇒ Boolean
46
47
48
49
50
|
# File 'tmpsets/set/mod017-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_sets ⇒ Object
74
75
76
|
# File 'tmpsets/set/mod022-rules/type/set.rb', line 74
def broader_sets
prototype.set_names[1..-1]
end
|
#directly_followed? ⇒ Boolean
52
53
54
|
# File 'tmpsets/set/mod017-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 'tmpsets/set/mod017-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
|
#follow_label ⇒ Object
16
17
18
19
20
21
22
|
# File 'tmpsets/set/mod017-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 'tmpsets/set/mod017-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 'tmpsets/set/mod017-follow/type/set.rb', line 32
def follow_set_card
self
end
|
#followed_by?(user_id = nil) ⇒ Boolean
28
29
30
|
# File 'tmpsets/set/mod017-follow/type/set.rb', line 28
def followed_by? user_id=nil
all_members_followed_by? user_id
end
|
#inheritable? ⇒ Boolean
10
11
12
13
14
15
|
# File 'tmpsets/set/mod022-rules/type/set.rb', line 10
def inheritable?
return true if junction_only?
name.trunk_name.junction? &&
name.tag_name.key == Card::Set::Self.pattern.key
end
|
#junction_only? ⇒ Boolean
24
25
26
27
28
29
30
|
# File 'tmpsets/set/mod022-rules/type/set.rb', line 24
def junction_only?
if @junction_only.nil?
@junction_only = subclass_for_set.junction_only
else
@junction_only
end
end
|
#label ⇒ Object
32
33
34
35
36
37
38
|
# File 'tmpsets/set/mod022-rules/type/set.rb', line 32
def label
if (klass = subclass_for_set)
klass.label name.left
else
""
end
end
|
#list_direct_followers? ⇒ Boolean
12
13
14
|
# File 'tmpsets/set/mod017-follow/type/set.rb', line 12
def list_direct_followers?
true
end
|
#prototype ⇒ Object
78
79
80
81
|
# File 'tmpsets/set/mod022-rules/type/set.rb', line 78
def prototype
opts = subclass_for_set.prototype_args name.trunk_name
Card.fetch opts[:name], new: opts
end
|
83
84
85
86
87
88
89
|
# File 'tmpsets/set/mod022-rules/type/set.rb', line 83
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
|
#setting_codenames_by_group ⇒ Object
52
53
54
55
56
57
58
59
60
|
# File 'tmpsets/set/mod022-rules/type/set.rb', line 52
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
17
18
19
20
21
22
|
# File 'tmpsets/set/mod022-rules/type/set.rb', line 17
def subclass_for_set
current_set_pattern_code = tag.codename
Card.set_patterns.find do |set|
current_set_pattern_code == set.pattern_code
end
end
|
#uncapitalized_label ⇒ Object
40
41
42
43
44
45
46
|
# File 'tmpsets/set/mod022-rules/type/set.rb', line 40
def uncapitalized_label
label = label.to_s
return label unless label[0]
label[0] = label[0].downcase
label
end
|
#visible_setting_codenames ⇒ Object
62
63
64
|
# File 'tmpsets/set/mod022-rules/type/set.rb', line 62
def visible_setting_codenames
@visible_setting_codenames ||= visible_settings.map(&:codename)
end
|
#visible_settings(group = nil) ⇒ Object
66
67
68
69
70
71
72
|
# File 'tmpsets/set/mod022-rules/type/set.rb', line 66
def visible_settings group=nil
settings =
(group && Card::Setting.groups[group]) || Card::Setting.groups.values.flatten.compact
settings.reject do |setting|
!setting || !setting.applies_to_cardtype(prototype.type_id)
end
end
|