12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/amee/rails.rb', line 12
def self.global(options = {})
unless @connection
$AMEE_CONFIG ||= {} if $AMEE_CONFIG['ssl'] == false
options.merge! :ssl => false
end
if $AMEE_CONFIG['retries']
options.merge! :retries => $AMEE_CONFIG['retries'].to_i
end
if $AMEE_CONFIG['timeout']
options.merge! :timeout => $AMEE_CONFIG['timeout'].to_i
end
if $AMEE_CONFIG['cache'] == 'rails'
options[:cache_store] = ActionController::Base.cache_store
else
options[:cache] ||= $AMEE_CONFIG['cache'] if $AMEE_CONFIG['cache'].present?
end
options[:enable_debug] ||= $AMEE_CONFIG['debug'] if $AMEE_CONFIG['debug'].present?
@connection = self.connect($AMEE_CONFIG['server'], $AMEE_CONFIG['username'], $AMEE_CONFIG['password'], options)
$amee = @connection
end
@connection
end
|