Module: Julewire::Core::Fields::Internal::Deletion
- Defined in:
- lib/julewire/core/fields/internal/deletion.rb
Class Method Summary collapse
- .apply_delete_paths!(target, paths) ⇒ Object
- .clear_delete_paths!(paths, fields) ⇒ Object
- .delete_path!(target, path) ⇒ Object
- .normalize_path(path) ⇒ Object
Class Method Details
.apply_delete_paths!(target, paths) ⇒ Object
16 17 18 |
# File 'lib/julewire/core/fields/internal/deletion.rb', line 16 def apply_delete_paths!(target, paths) paths.each { delete_path!(target, it) } end |
.clear_delete_paths!(paths, fields) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/julewire/core/fields/internal/deletion.rb', line 20 def clear_delete_paths!(paths, fields) additions = field_paths(fields) paths.reject! do |path| additions.any? { path_overlap?(path, it) } end end |
.delete_path!(target, path) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/julewire/core/fields/internal/deletion.rb', line 9 def delete_path!(target, path) normalized_path = normalize_path(path) return target if normalized_path.empty? deep_delete_path!(target, normalized_path) end |
.normalize_path(path) ⇒ Object
27 28 29 |
# File 'lib/julewire/core/fields/internal/deletion.rb', line 27 def normalize_path(path) Array(path).flatten.map { Internal.normalize_key(it) } end |