Module: Card::Set::All::Templating
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod001-01_core/all/templating.rb
Instance Method Summary
collapse
Methods included from Card::Set
abstract_set?, all_set?, card_accessor, card_reader, card_writer, clean_empty_module_from_hash, clean_empty_modules, define_active_job, define_event_method, define_event_perform_later_method, define_on_format, ensure_set, event, extended, format, phase_method, process_base_module_list, process_base_modules, register_set, register_set_format, shortname, view, write_tmp_file
Instance Method Details
#assign_type_to?(structure) ⇒ Boolean
42
43
44
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 42
def assign_type_to? structure
type_id != structure.type_id and structure.assigns_type?
end
|
#assigns_type? ⇒ Boolean
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 98
def assigns_type?
if is_structure?
if set_pattern = Card.fetch( cardname.trunk_name.tag_name, skip_modules: true )
pattern_code = set_pattern.codename and
set_class = Card::SetPattern.find( pattern_code ) and
set_class.assigns_type
end
end
end
|
#expire_structuree_references ⇒ Object
FIXME: content settings – do we really need the reference expiration system?
I kind of think so. otherwise how do we handled patterned references in hard-templated cards? I’ll leave the FIXME here until the need (and/or other solution) is well documented. -efm
80
81
82
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 80
def expire_structuree_references
update_structurees references_expired: 1
end
|
#is_structure? ⇒ Boolean
9
10
11
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 9
def is_structure?
cardname.trait_name? :structure
end
|
#is_template? ⇒ Boolean
~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/templating.rb ~~~~~~~~~~~
5
6
7
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 5
def is_template?
cardname.trait_name? :structure, :default
end
|
#structure ⇒ Object
46
47
48
49
50
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 46
def structure
if template && template.is_structure?
template
end
end
|
#structure_rule_card ⇒ Object
60
61
62
63
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 60
def structure_rule_card
card = rule_card :structure, skip_modules: true
card && card.db_content.strip == '_self' ? nil : card
end
|
#structuree_names ⇒ Object
65
66
67
68
69
70
71
72
73
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 65
def structuree_names
if wql = structuree_spec
Auth.as_bot do
Card::Query.run(wql.merge return: :name)
end
else
[]
end
end
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 13
def template
@template ||= begin
@virtual = false
if new_card?
default = rule_card :default, skip_modules: true
dup_card = dup
dup_card.type_id = default ? default.type_id : Card.default_type_id
if structure = dup_card.structure_rule_card
@virtual = true if junction?
self.type_id = structure.type_id if assign_type_to?(structure)
structure
else
default
end
elsif structure = structure_rule_card
repair_type structure.type_id if assign_type_to?(structure)
structure
end
end
end
|
#update_structurees(args) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 84
def update_structurees args
if query = structuree_spec
Auth.as_bot do
query[:return] = :id
Card::Query.run(query).each_slice(100) do |id_batch|
Card.where( id: id_batch ).update_all args
end
end
end
end
|
#virtual? ⇒ Boolean
52
53
54
55
56
57
58
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 52
def virtual?
return false unless new_card?
if @virtual.nil?
cardname.simple? ? @virtual=false : template
end
@virtual
end
|