Module: Astrotrain

Defined in:
lib/astrotrain.rb,
lib/astrotrain/tmail.rb,
lib/astrotrain/worker.rb,
lib/astrotrain/mapping.rb,
lib/astrotrain/message.rb,
lib/astrotrain/logged_mail.rb,
lib/astrotrain/mapping/http_post.rb,
lib/astrotrain/mapping/transport.rb

Defined Under Namespace

Classes: LoggedMail, Mail, Mapping, Message, Worker

Constant Summary collapse

CALLBACK_TYPES =
[:pre_mapping, :pre_processing, :post_processing]

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.callbacksObject

Returns the value of attribute callbacks.



4
5
6
# File 'lib/astrotrain.rb', line 4

def callbacks
  @callbacks
end

.lib_rootObject

Returns the value of attribute lib_root.



4
5
6
# File 'lib/astrotrain.rb', line 4

def lib_root
  @lib_root
end

.rootObject

Returns the value of attribute root.



4
5
6
# File 'lib/astrotrain.rb', line 4

def root
  @root
end

Class Method Details

.callback(name, *args, &block) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/astrotrain.rb', line 18

def self.callback(name, *args, &block)
  found = callbacks[name]
  if block
    found << block
  else
    found.each { |cback| cback.call(*args) }
  end
  found
end

.clear_callbacksObject



28
29
30
# File 'lib/astrotrain.rb', line 28

def self.clear_callbacks
  self.callbacks = CALLBACK_TYPES.inject({}) { |memo, ctype| memo.update(ctype => []) }
end

.load(root = Dir.pwd) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/astrotrain.rb', line 7

def self.load(root = Dir.pwd)
  self.root     = File.expand_path(root)
  self.lib_root = File.expand_path(File.dirname(__FILE__))
  load_dependencies
  yield if block_given?
  %w(tmail message mapping logged_mail mapping/transport mapping/http_post mapping/jabber).each do |lib|
    require "astrotrain/#{lib}"
  end
  Astrotrain::Mail::ALLOW_MULTIPLE['delivered-to'] = true
end