Sha256: 450b3f550c23e907c8f3b0645f5ee53f80bbf1ee58fcc4d13afdb2dd071afcd3

Contents?: true

Size: 752 Bytes

Versions: 1

Compression:

Stored size: 752 Bytes

Contents

require 'mail'
require 'pstore'

module Devmail
  class Storage
    def initialize
      @store = PStore.new(File.join(Rails.root, "tmp", "devmail.pstore"))
      @store.transaction { @store[:messages] = [] }
    end

    def all
      @store.transaction { @store[:messages] }
    end

    def at(index)
      @store.transaction { @store[:messages][index] }
    end

    def add(message)
      @store.transaction { @store[:messages] << message }
    end

    def index(message)
      @store.transaction { @store[:messages].index(message) }
    end

    def remove(message)
      @store.transaction { @store[:messages].delete(message) }
    end

    def remove_at(index)
      @store.transaction { @store[:messages].delete_at(index) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devmail-0.1.0 lib/devmail/storage.rb