Module: Configue::HashNode
- Defined in:
- lib/configue/hash_node.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #assoc(key) ⇒ Object
- #fetch(key) ⇒ Object
- #key?(key) ⇒ Boolean (also: #has_key?, #include?, #member?)
- #to_hash ⇒ Object
- #values_at(*keys) ⇒ Object
Instance Method Details
#[](key) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/configue/hash_node.rb', line 5 def [](key) k = key.to_s v = @container[k] @container[k] = self.class.new(v) if node?(v) @container[k] end |
#assoc(key) ⇒ Object
27 28 29 30 |
# File 'lib/configue/hash_node.rb', line 27 def assoc(key) k = key.to_s @container.assoc(k) end |
#fetch(key) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/configue/hash_node.rb', line 12 def fetch(key) k = key.to_s v = @container[key] @container[k] = self.class.new(v) if node?(v) @container.fetch(k) end |
#key?(key) ⇒ Boolean Also known as: has_key?, include?, member?
19 20 21 22 |
# File 'lib/configue/hash_node.rb', line 19 def key?(key) k = key.to_s @container.key?(k) end |
#to_hash ⇒ Object
32 33 34 |
# File 'lib/configue/hash_node.rb', line 32 def to_hash @container.dup end |
#values_at(*keys) ⇒ Object
36 37 38 39 |
# File 'lib/configue/hash_node.rb', line 36 def values_at(*keys) ks = keys.map {|k| k.to_s } @container.values_at(*ks) end |