Class: Transmogrifier::HashNode
- Extended by:
- Forwardable
- Defined in:
- lib/transmogrifier/nodes/hash_node.rb
Instance Method Summary collapse
- #clone(key) ⇒ Object
- #find_all(keys) ⇒ Object
-
#initialize(hash) ⇒ HashNode
constructor
A new instance of HashNode.
Methods inherited from Node
#append, #delete, for, #modify, #raw
Constructor Details
#initialize(hash) ⇒ HashNode
Returns a new instance of HashNode.
7 8 9 |
# File 'lib/transmogrifier/nodes/hash_node.rb', line 7 def initialize(hash) @hash = hash end |
Instance Method Details
#clone(key) ⇒ Object
23 24 25 26 |
# File 'lib/transmogrifier/nodes/hash_node.rb', line 23 def clone(key) matching_node = @hash[key] Marshal.load(Marshal.dump(matching_node)) end |
#find_all(keys) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/transmogrifier/nodes/hash_node.rb', line 11 def find_all(keys) first_key, *remaining_keys = keys if first_key.nil? [self] elsif child = @hash[first_key] Node.for(child, self).find_all(remaining_keys) else [] end end |