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, ProcessingCancelled, 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.



6
7
8
# File 'lib/astrotrain.rb', line 6

def callbacks
  @callbacks
end

.lib_rootObject

Returns the value of attribute lib_root.



6
7
8
# File 'lib/astrotrain.rb', line 6

def lib_root
  @lib_root
end

.rootObject

Returns the value of attribute root.



6
7
8
# File 'lib/astrotrain.rb', line 6

def root
  @root
end

Class Method Details

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



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

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



30
31
32
# File 'lib/astrotrain.rb', line 30

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

.load(root = Dir.pwd) ⇒ Object



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

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