Class: Rho::RhoConfig
- Inherits:
-
Object
- Object
- Rho::RhoConfig
- Defined in:
- lib/rho/rho.rb
Overview
Generic configuration class which accepts hashes with unique keys
Constant Summary collapse
- @@sources =
{}
- @@config =
{'start_path' => '/app', 'options_path' => '/app/Settings'}
Class Method Summary collapse
- .add_config(key, value) ⇒ Object
- .add_source(modelname, new_source = nil) ⇒ Object
- .config ⇒ Object
- .method_missing(name, *args) ⇒ Object
- .sources ⇒ Object
Class Method Details
.add_config(key, value) ⇒ Object
263 264 265 |
# File 'lib/rho/rho.rb', line 263 def add_config(key,value) @@config[key] = value if key # allow nil value end |
.add_source(modelname, new_source = nil) ⇒ Object
267 268 269 270 271 272 273 274 |
# File 'lib/rho/rho.rb', line 267 def add_source(modelname, new_source=nil) if new_source unless @@sources[new_source] @@sources[modelname] = new_source @@sources[modelname]['name'] ||= modelname end end end |
.config ⇒ Object
259 260 261 |
# File 'lib/rho/rho.rb', line 259 def config @@config end |
.method_missing(name, *args) ⇒ Object
241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/rho/rho.rb', line 241 def method_missing(name, *args) unless name == Fixnum varname = name.to_s.gsub(/\=/,"") setting = (name.to_s =~ /=/) if setting @@config[varname] = args[0] # save changes to file RhoConf.set_property_by_name(varname,args[0]) else @@config[varname] end end end |
.sources ⇒ Object
255 256 257 |
# File 'lib/rho/rho.rb', line 255 def sources @@sources end |