Class: MailCatcher::API::Mailbox

Inherits:
Object
  • Object
show all
Defined in:
lib/mailcatcher/api/mailbox.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMailbox

Returns a new instance of Mailbox.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/mailcatcher/api/mailbox.rb', line 6

def initialize
  @server = MailCatcher::API.config.server

  @connection = Faraday.new(url: @server) do |faraday|
    faraday.request :network_exception
    faraday.adapter :net_http
  end

  @messages_index = nil
  @messages = nil
end

Instance Attribute Details

#serverObject (readonly)

Returns the value of attribute server.



4
5
6
# File 'lib/mailcatcher/api/mailbox.rb', line 4

def server
  @server
end

Instance Method Details

#countObject



23
24
25
# File 'lib/mailcatcher/api/mailbox.rb', line 23

def count
  messages_index.count
end

#messagesObject



27
28
29
# File 'lib/mailcatcher/api/mailbox.rb', line 27

def messages
  @messages ||= load_messages
end

#refreshObject



18
19
20
21
# File 'lib/mailcatcher/api/mailbox.rb', line 18

def refresh
  load_messages_index
  load_messages unless @messages.nil?
end