Class: DeadSimpleConf::ConfigBlock
- Inherits:
-
Object
- Object
- DeadSimpleConf::ConfigBlock
- Defined in:
- lib/dead_simple_conf.rb
Class Method Summary collapse
Instance Method Summary collapse
- #_load_data(attributes) ⇒ Object
-
#initialize(attributes) ⇒ ConfigBlock
constructor
A new instance of ConfigBlock.
Constructor Details
#initialize(attributes) ⇒ ConfigBlock
Returns a new instance of ConfigBlock.
15 16 17 |
# File 'lib/dead_simple_conf.rb', line 15 def initialize(attributes) _load_data(attributes) end |
Class Method Details
.sub_section(name, klass) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/dead_simple_conf.rb', line 7 def self.sub_section(name, klass) attr_reader(name) define_method("#{name}=") do |h| instance_variable_set("@#{name}", klass.new(h)) end end |
Instance Method Details
#_load_data(attributes) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/dead_simple_conf.rb', line 19 def _load_data(attributes) unknown = attributes.reject do |key, value| if respond_to?("#{key}=") send("#{key}=", value) true else false end end unless unknown.empty? fail "unknown parameter(s) in config block #{self.class}: #{unknown.inspect}" end end |