Class: SysConfig
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SysConfig
- Defined in:
- app/models/sys_config.rb
Overview
The sys_config table stores the system configuration for a Sugoi-Mail This includes things like the mail server and the default mailing list class for new users.
sys_config has the following data members, although you probably won’t need to know them due to the fact that you access configuration parameters directly rather than by searching for them:
name
-
The name of the configuration parameter.
value
-
The value of the configuration parameter. This is serialized as YAML for the moment, until the YAML storage format starts presenting problems.
To use this library, simply refer to SysConfig.parameter_name. For example, if the SMTP host were stored in the parameter “smtphost”, you’d retrieve it with a simple
SysConfig.smtphost
and you’d set it with:
SysConfig.smtphost = "localhost"
Class Method Summary collapse
Class Method Details
.method_missing(meth, *args) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/sys_config.rb', line 26 def self.method_missing meth, *args begin super(meth, *args) rescue NoMethodError config_param = meth.to_s if config_param =~ /\=$/ then if args.length > 1 then raise ArgumentError, "How did you manage that?" end config_param.sub! /\=$/,'' conf = self.find_or_create_by_name config_param conf.value = args[0] if conf.save return conf end else conf = self.find_by_name config_param unless conf raise ActiveRecord::RecordNotFound, "config param #{config_param} does not exist" end conf.value end end end |