Class: Fairy::Conf
- Inherits:
-
Object
- Object
- Fairy::Conf
- Defined in:
- lib/fairy/share/conf.rb
Overview
}
Direct Known Subclasses
Defined Under Namespace
Classes: DefaultConf
Constant Summary collapse
- PROPS =
[]
Class Method Summary collapse
- .configure_common_conf ⇒ Object
- .def_prop(prop, reader = nil, setter = nil) ⇒ Object
- .def_prop_relative_path(prop, path, base_prop = :HOME) ⇒ Object (also: def_rpath)
Instance Method Summary collapse
- #base_conf=(conf) ⇒ Object
- #HOME ⇒ Object
-
#initialize(super_conf = nil, opts = {}) ⇒ Conf
constructor
A new instance of Conf.
- #props ⇒ Object
- #set_values(hash) ⇒ Object
- #value(prop) ⇒ Object
Constructor Details
#initialize(super_conf = nil, opts = {}) ⇒ Conf
Returns a new instance of Conf.
26 27 28 29 |
# File 'lib/fairy/share/conf.rb', line 26 def initialize(super_conf = nil, opts = {}) @super_conf = super_conf @values = opts end |
Class Method Details
.configure_common_conf ⇒ Object
417 418 419 420 421 422 423 424 425 |
# File 'lib/fairy/share/conf.rb', line 417 def Conf.configure_common_conf Thread.abort_on_exception = CONF.DEBUG_THREAD_ABORT_ON_EXCEPTION TCPSocket.do_not_reverse_lookup = CONF.SOCK_DO_NOT_REVERSE_LOOKUP if CONF.USE_RESOLV_REPLACE require "resolv-replace" end end |
.def_prop(prop, reader = nil, setter = nil) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/fairy/share/conf.rb', line 32 def def_prop(prop, reader = nil, setter = nil) PROPS.push prop reader = "def #{prop}; value(:#{prop}); end" unless reader setter = "def #{prop}=(value); @values[:#{prop}] = value; end" unless setter module_eval reader module_eval setter # DefaultConf.module_eval reader end |
.def_prop_relative_path(prop, path, base_prop = :HOME) ⇒ Object Also known as: def_rpath
41 42 43 44 |
# File 'lib/fairy/share/conf.rb', line 41 def def_prop_relative_path(prop, path, base_prop = :HOME) def_prop(prop, "def #{prop}; value(:#{prop}) || self.#{base_prop}+'/'+'#{path}'; end") end |
Instance Method Details
#base_conf=(conf) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/fairy/share/conf.rb', line 59 def base_conf=(conf) if @super_conf @super_conf.base_conf = conf else @super_conf = conf end end |
#HOME ⇒ Object
78 79 80 |
# File 'lib/fairy/share/conf.rb', line 78 def HOME File.(value(:HOME)) end |
#props ⇒ Object
55 56 57 |
# File 'lib/fairy/share/conf.rb', line 55 def props PROPS end |
#set_values(hash) ⇒ Object
67 68 69 70 71 |
# File 'lib/fairy/share/conf.rb', line 67 def set_values(hash) for key, value in hash @values[key] = value end end |
#value(prop) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/fairy/share/conf.rb', line 48 def value(prop) if (v = @values[prop]).nil? @super_conf && v = @super_conf.value(prop) end v end |