Sha256: 7b47678b56885e15466f9b034ad7be25a71be692664fadc2090eb334b1a03e0d

Contents?: true

Size: 952 Bytes

Versions: 20

Compression:

Stored size: 952 Bytes

Contents

class TextDocumentContent < DocumentContent

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

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

  # Return document file size (= version's text size).
  def size(format=nil)
    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

20 entries across 20 versions & 1 rubygems

Version Path
zena-1.2.8 app/models/text_document_content.rb
zena-1.2.7 app/models/text_document_content.rb
zena-1.2.6 app/models/text_document_content.rb
zena-1.2.5 app/models/text_document_content.rb
zena-1.2.4 app/models/text_document_content.rb
zena-1.2.3 app/models/text_document_content.rb
zena-1.2.2 app/models/text_document_content.rb
zena-1.2.1 app/models/text_document_content.rb
zena-1.2.0 app/models/text_document_content.rb
zena-1.1.3 app/models/text_document_content.rb
zena-1.1.2 app/models/text_document_content.rb
zena-1.1.1 app/models/text_document_content.rb
zena-1.1.0 app/models/text_document_content.rb
zena-1.0.0 app/models/text_document_content.rb
zena-1.0.0.rc3 app/models/text_document_content.rb
zena-1.0.0.rc2 app/models/text_document_content.rb
zena-1.0.0.rc1 app/models/text_document_content.rb
zena-1.0.0.beta3 app/models/text_document_content.rb
zena-1.0.0.beta2 app/models/text_document_content.rb
zena-1.0.0.beta1 app/models/text_document_content.rb