Class: Nyara::ConfigHash

Inherits:
ParamHash show all
Defined in:
lib/nyara/hashes/config_hash.rb,
ext/hashes.c

Overview

Extended hash class for the use in configuration.

Direct Known Subclasses

NyaraConfig

Instance Method Summary collapse

Methods inherited from ParamHash

#_aref, #_aset, #key?, #nested_aref, #nested_aset, parse_cookie, parse_param, split_name

Methods inherited from Hash

#to_param

Instance Method Details

#[](*keys) ⇒ Object

Call-seq

config['a', 'very', 'deep', '', 'key']

Equivalent to

config['a']['very']['deep'].last['key'] rescue nil

12
13
14
# File 'lib/nyara/hashes/config_hash.rb', line 12

def [] *keys
  nested_aref keys.map(&:to_s)
end

#[]=(*keys, value) ⇒ Object

Call-seq

config['a', 'very', 'deep', 'key'] = value

All intermediate level ConfigHashes are created automatically


21
22
23
# File 'lib/nyara/hashes/config_hash.rb', line 21

def []= *keys, value
  nested_aset keys.map(&:to_s), value
end