Class: KNSEmailEndpoint::Configuration
- Inherits:
-
Object
- Object
- KNSEmailEndpoint::Configuration
- Defined in:
- lib/kns_email_endpoint/configuration.rb
Class Method Summary collapse
-
.[](name) ⇒ Object
Connection Handling.
- .connections ⇒ Object
- .each_connection ⇒ Object
- .load_from_file(yaml_file) ⇒ Object
- .log ⇒ Object
- .log_level=(l) ⇒ Object
- .logdir ⇒ Object
- .poll_delay ⇒ Object
- .storage ⇒ Object
- .storage=(opts) ⇒ Object
- .to_h ⇒ Object
-
.work_threads ⇒ Object
defaults.
Class Method Details
.[](name) ⇒ Object
Connection Handling
69 70 71 72 73 74 |
# File 'lib/kns_email_endpoint/configuration.rb', line 69 def [](name) @@connections.each do |conn| return conn if conn["name"] == name end raise "Invalid connection (#{name})" end |
.connections ⇒ Object
64 |
# File 'lib/kns_email_endpoint/configuration.rb', line 64 def connections; @@connections ||= [] end |
.each_connection ⇒ Object
76 77 78 79 80 |
# File 'lib/kns_email_endpoint/configuration.rb', line 76 def each_connection @@connections.each do |conn| yield Connection.new conn["name"] end end |
.load_from_file(yaml_file) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/kns_email_endpoint/configuration.rb', line 14 def load_from_file(yaml_file) conf = YAML.load_file(yaml_file) @@logdir = conf["logdir"] if conf["logdir"] @@work_threads = conf["workthreads"] if conf["workthreads"] @@poll_delay = conf["polldelayinseconds"] if conf["polldelayinseconds"] @@log_level = conf["logginglevel"] if conf["logginglevel"] @@connections = conf["connections"] if conf["connections"] self.storage = conf["storage"] || {} end |
.log ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/kns_email_endpoint/configuration.rb', line 34 def log return @@logger if defined?(@@logger) && ! @logger.nil? if @@logdir && ! @@logdir.empty? FileUtils.mkdir_p @@logdir unless @@logdir == "" || @@logdir.nil? log_dest = File.join(@@logdir, 'email_endpoint.log') else log_dest = STDOUT end @@logger = Logger.new(log_dest, "daily") @@logger.level = eval("Logger::#{@@log_level.upcase}") rescue Logger::DEBUG return @@logger end |
.log_level=(l) ⇒ Object
47 48 49 50 51 |
# File 'lib/kns_email_endpoint/configuration.rb', line 47 def log_level=(l) @@log_level = l @@log = nil return @@log_level end |
.logdir ⇒ Object
63 |
# File 'lib/kns_email_endpoint/configuration.rb', line 63 def logdir; @@logdir ||= "" end |
.poll_delay ⇒ Object
62 |
# File 'lib/kns_email_endpoint/configuration.rb', line 62 def poll_delay; @@poll_delay ||= 30 end |
.storage ⇒ Object
65 |
# File 'lib/kns_email_endpoint/configuration.rb', line 65 def storage; @@storage ||= {} end |
.storage=(opts) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/kns_email_endpoint/configuration.rb', line 53 def storage=(opts) @@storage = opts engine = opts.delete("engine") @@storage_engine = MessageState.set_storage(engine, opts) return @@storage end |
.to_h ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/kns_email_endpoint/configuration.rb', line 24 def to_h { :logdir => logdir, :work_threads => work_threads, :poll_delay => poll_delay, :storage => storage, :connections => connections } end |
.work_threads ⇒ Object
defaults
61 |
# File 'lib/kns_email_endpoint/configuration.rb', line 61 def work_threads; @@work_threads ||= 10 end |