Class: Received::Backend::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/received/backend/base.rb

Direct Known Subclasses

Mongodb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_observer(observer) ⇒ Object



24
25
26
# File 'lib/received/backend/base.rb', line 24

def add_observer(observer)
  observers.push(observer)
end

.notify_observers(method, payload) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/received/backend/base.rb', line 32

def notify_observers(method, payload)
  observers.each do |observer|
    if observer.respond_to?(method)
      observer.send(method, payload) rescue nil
    end
  end
end

.observersObject



20
21
22
# File 'lib/received/backend/base.rb', line 20

def observers
  @@observers ||= []
end

.remove_observer(observer) ⇒ Object



28
29
30
# File 'lib/received/backend/base.rb', line 28

def remove_observer(observer)
  observers.delete(observer)
end

Instance Method Details

#notify_observers(*args) ⇒ Object



15
16
17
# File 'lib/received/backend/base.rb', line 15

def notify_observers(*args)
  self.class.notify_observers(*args)
end

#store(mail) ⇒ Object

This method is abstract.

Stores the data

Parameters:

  • mail (Hash)

Options Hash (mail):

  • :from (String)
  • :rcpt (Array)
  • :body (String)

Raises:

  • (NotImplementedError)


11
12
13
# File 'lib/received/backend/base.rb', line 11

def store(mail)
  raise NotImplementedError
end