Module: DevSuite::Utils::Data::PathAccess::KeyHandler
- Extended by:
- KeyHandler
- Included in:
- KeyHandler
- Defined in:
- lib/dev_suite/utils/data/path_access/key_handler.rb
Instance Method Summary collapse
-
#find_key(hash, key) ⇒ Object
Find an existing key in a hash, handling both symbol and string keys.
-
#validate_path(data, key) ⇒ Object
Validate the path by checking if it’s pointing to a valid data structure.
Instance Method Details
#find_key(hash, key) ⇒ Object
Find an existing key in a hash, handling both symbol and string keys
11 12 13 14 15 16 17 |
# File 'lib/dev_suite/utils/data/path_access/key_handler.rb', line 11 def find_key(hash, key) return key if hash.key?(key) return key.to_s if hash.key?(key.to_s) return key.to_sym if hash.key?(key.to_sym) key end |
#validate_path(data, key) ⇒ Object
Validate the path by checking if it’s pointing to a valid data structure
20 21 22 |
# File 'lib/dev_suite/utils/data/path_access/key_handler.rb', line 20 def validate_path(data, key) raise InvalidPathError, "Invalid path at '#{key}'" if data.nil? end |