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, 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
41
42
43
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 41
def assign_type_to? structure
type_id != structure.type_id and structure.assigns_type?
end
|
#assigns_type? ⇒ Boolean
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 96
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
79
80
81
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 79
def expire_structuree_references
update_structurees :references_expired => 1
end
|
#is_structure? ⇒ Boolean
8
9
10
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 8
def is_structure?
cardname.trait_name? :structure
end
|
#is_template? ⇒ Boolean
4
5
6
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 4
def is_template?
cardname.trait_name? :structure, :default
end
|
#structure ⇒ Object
45
46
47
48
49
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 45
def structure
if template && template.is_structure?
template
end
end
|
#structure_rule_card ⇒ Object
59
60
61
62
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 59
def structure_rule_card
card = rule_card :structure, :skip_modules=>true
card && card.db_content.strip == '_self' ? nil : card
end
|
#structuree_names ⇒ Object
64
65
66
67
68
69
70
71
72
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 64
def structuree_names
if wql = structuree_spec
Auth.as_bot do
Card::Query.new(wql.merge :return=>:name).run
end
else
[]
end
end
|
12
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
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 12
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
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 83
def update_structurees args
if query = structuree_spec
Auth.as_bot do
Card::Query.new( query.merge(:return => :id) ).run.each_slice(100) do |id_batch|
Card.where( :id => id_batch ).update_all args
end
end
end
end
|
#virtual? ⇒ Boolean
51
52
53
54
55
56
57
|
# File 'tmpsets/set/mod001-01_core/all/templating.rb', line 51
def virtual?
return false unless new_card?
if @virtual.nil?
cardname.simple? ? @virtual=false : template
end
@virtual
end
|