Method: Collab::Models::Document#to_html
- Defined in:
- lib/collab/models/document.rb
#to_html ⇒ Object
Serialize the document to html, uses cached if possible. Note that this may lock the document
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/collab/models/document.rb', line 14 def to_html return serialized_html if serialized_html serialized_version = self.document_version ::Collab::JS.document_to_html(self.content, schema_name: schema_name).tap do |serialized_html| Thread.new do # use a thread to prevent deadlocks and avoid incuring the cost of an inline-write self.with_lock do self.update_attribute(:serialized_html, serialized_html) if serialized_version == self.version and self.serialized_html.nil? end end end end |