Class: Lcms::Engine::Document
Constant Summary
collapse
- GOOGLE_URL_PREFIX =
'https://docs.google.com/document/d'
Instance Method Summary
collapse
Methods included from Partable
#create_parts_for, #layout
Instance Method Details
#activate! ⇒ Object
65
66
67
68
69
70
71
72
|
# File 'app/models/lcms/engine/document.rb', line 65
def activate!
self.class.transaction do
self.class.where(resource_id: resource_id).where.not(id: id).update_all active: false
update_columns active: true
end
end
|
#assessment? ⇒ Boolean
74
75
76
|
# File 'app/models/lcms/engine/document.rb', line 74
def assessment?
resource&.assessment?
end
|
#ela? ⇒ Boolean
78
79
80
|
# File 'app/models/lcms/engine/document.rb', line 78
def ela?
metadata['subject'].to_s.casecmp('ela').zero?
end
|
#file_fs_url ⇒ Object
88
89
90
91
92
|
# File 'app/models/lcms/engine/document.rb', line 88
def file_fs_url
return unless foundational_file_id.present?
"#{GOOGLE_URL_PREFIX}/#{foundational_file_id}"
end
|
#file_url ⇒ Object
82
83
84
85
86
|
# File 'app/models/lcms/engine/document.rb', line 82
def file_url
return unless file_id.present?
"#{GOOGLE_URL_PREFIX}/#{file_id}"
end
|
#foundational? ⇒ Boolean
94
95
96
|
# File 'app/models/lcms/engine/document.rb', line 94
def foundational?
metadata['type'].to_s.casecmp('fs').zero?
end
|
#gdoc_material_ids ⇒ Object
98
99
100
|
# File 'app/models/lcms/engine/document.rb', line 98
def gdoc_material_ids
materials.gdoc.pluck(:id)
end
|
#materials_anchors ⇒ Object
102
103
104
105
106
107
108
109
110
111
|
# File 'app/models/lcms/engine/document.rb', line 102
def materials_anchors
{}.tap do |materials_with_anchors|
toc.collect_children.each do |x|
x.material_ids.each do |m|
materials_with_anchors[m] ||= { optional: [], anchors: [] }
materials_with_anchors[m][x.optional ? :optional : :anchors] << x.anchor
end
end
end
end
|
#math? ⇒ Boolean
113
114
115
|
# File 'app/models/lcms/engine/document.rb', line 113
def math?
metadata['subject'].to_s.casecmp('math').zero?
end
|
#ordered_material_ids ⇒ Object
117
118
119
|
# File 'app/models/lcms/engine/document.rb', line 117
def ordered_material_ids
toc.ordered_material_ids
end
|
#tmp_link(key) ⇒ Object
121
122
123
124
125
126
127
128
|
# File 'app/models/lcms/engine/document.rb', line 121
def tmp_link(key)
url = links[key]
with_lock do
reload.links.delete(key)
update links: links
end
url
end
|