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-1.2 lib/sup/modes/resume_mode.rb
sup-1.1 lib/sup/modes/resume_mode.rb
sup-1.0 lib/sup/modes/resume_mode.rb
sup-0.23 lib/sup/modes/resume_mode.rb
sup-0.22.1 lib/sup/modes/resume_mode.rb
sup-0.22.0 lib/sup/modes/resume_mode.rb
sup-0.21.0 lib/sup/modes/resume_mode.rb
sup-0.20.0 lib/sup/modes/resume_mode.rb
sup-0.19.0 lib/sup/modes/resume_mode.rb
sup-0.18.0 lib/sup/modes/resume_mode.rb
sup-0.17.0 lib/sup/modes/resume_mode.rb
sup-0.16.0 lib/sup/modes/resume_mode.rb
sup-0.15.4 lib/sup/modes/resume_mode.rb
sup-0.15.3 lib/sup/modes/resume_mode.rb
sup-0.15.2 lib/sup/modes/resume_mode.rb
sup-0.15.1 lib/sup/modes/resume_mode.rb
sup-0.15.0 lib/sup/modes/resume_mode.rb
sup-0.14.1.1 lib/sup/modes/resume_mode.rb
sup-0.13.2.1 lib/sup/modes/resume_mode.rb
sup-0.14.1 lib/sup/modes/resume_mode.rb