Module: Mailbin

Defined in:
lib/mailbin.rb,
lib/mailbin/engine.rb,
lib/mailbin/version.rb,
lib/mailbin/delivery_method.rb,
lib/mailbin/inline_preview_interceptor.rb,
app/controllers/mailbin/clears_controller.rb,
app/controllers/mailbin/messages_controller.rb

Defined Under Namespace

Classes: ApplicationController, ClearsController, DeliveryMethod, Engine, InlinePreviewInterceptor, MessagesController

Constant Summary collapse

VERSION =
"1.0.0"

Class Method Summary collapse

Class Method Details

.allObject



11
12
13
14
15
# File 'lib/mailbin.rb', line 11

def all
  Dir.glob("*.eml", base: settings[:location]).map do |message_id|
    find(message_id)
  end.sort_by(&:date).reverse!
end

.destroy(message_id) ⇒ Object



21
22
23
# File 'lib/mailbin.rb', line 21

def destroy(message_id)
  File.delete location_for(message_id)
end

.destroy_allObject



25
26
27
28
29
# File 'lib/mailbin.rb', line 25

def destroy_all
  Dir.glob("*.eml", base: settings[:location]).map do |message_id|
    destroy(message_id)
  end
end

.find(message_id) ⇒ Object



17
18
19
# File 'lib/mailbin.rb', line 17

def find(message_id)
  InlinePreviewInterceptor.previewing_email Mail.read(location_for(message_id))
end

.location_for(message_id) ⇒ Object



31
32
33
34
# File 'lib/mailbin.rb', line 31

def location_for(message_id)
  message_id += ".eml" unless message_id.end_with?(".eml")
  File.join(settings[:location], message_id)
end

.settingsObject



36
37
38
# File 'lib/mailbin.rb', line 36

def settings
  ActionMailer::Base.mailbin_settings
end