Sha256: 9d0bba5232335e6aa8f177ca5f92d3cef17cba30c75b2b130f7f752fc4752a14

Contents?: true

Size: 976 Bytes

Versions: 13

Compression:

Stored size: 976 Bytes

Contents

class TextDocumentContent < DocumentContent

  def file=(aFile)
    super
    version.text = @new_file.read
  end

  def file(mode=nil)
    @loaded_file ||= @new_file || StringIO.new(version.text)
  end

  # Return document file size (= version's text size).
  def size(format=nil)
    version.text.size
  end

  def filename
    version.node.filename
  end

  private

  def valid_file
    true # overwrite superclass behaviour
  end

  # called before_save. Replace behaviour of TextDocuments.
  def content_before_save
    self[:type] = self.class.to_s # make sure the type is set in case no sub-classes are loaded.

    if @new_file
      # nothing to do
    elsif !new_record? && (old = DocumentContent.find(self[:id])).name != self[:name]
      # TODO: clear cache
    end
  end

  def make_file(path, data)
    # TODO: raise error
  end

  def destroy_file
    # TODO: clear cache
    # TODO: set content_id of versions whose content_id was self[:version_id]
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
zena-0.16.9 app/models/text_document_content.rb
zena-0.16.8 app/models/text_document_content.rb
zena-0.16.7 app/models/text_document_content.rb
zena-0.16.6 app/models/text_document_content.rb
zena-0.16.5 app/models/text_document_content.rb
zena-0.16.4 app/models/text_document_content.rb
zena-0.16.3 app/models/text_document_content.rb
zena-0.16.2 app/models/text_document_content.rb
zena-0.16.1 app/models/text_document_content.rb
zena-0.16.0 app/models/text_document_content.rb
zena-0.15.2 app/models/text_document_content.rb
zena-0.15.1 app/models/text_document_content.rb
zena-0.15.0 app/models/text_document_content.rb