Sha256: adc27775475b8e065e6b93ab32d97c7509ded76e69e579b255d9d6b4a41acbb3

Contents?: true

Size: 992 Bytes

Versions: 24

Compression:

Stored size: 992 Bytes

Contents

module Redwood

class ResumeMode < EditMessageMode
  def initialize m
    @m = m
    @safe = false

    header, body = parse_file m.draft_filename
    header.delete "Date"

    super :header => header, :body => body, :have_signature => true
  rescue Errno::ENOENT
    DraftManager.discard @m
    BufferManager.flash "Draft deleted outside of sup."
  end

  def unsaved?; !@safe end

  def killable?
    return true if @safe

    case BufferManager.ask_yes_or_no "Discard draft?"
    when true
      DraftManager.discard @m
      BufferManager.flash "Draft discarded."
      true
    when false
      if edited?
        DraftManager.write_draft { |f| write_message f, false }
        DraftManager.discard @m
        BufferManager.flash "Draft saved."
      end
      true
    else
      false
    end
  end

  def send_message
    if super
      DraftManager.discard @m
      @safe = true
    end
  end

  def save_as_draft
    @safe = true
    DraftManager.discard @m if super
  end
end

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
sup-0.14.0 lib/sup/modes/resume_mode.rb
sup-0.13.2 lib/sup/modes/resume_mode.rb
sup-0.13.1 lib/sup/modes/resume_mode.rb
sup-0.13.0 lib/sup/modes/resume-mode.rb