Module: Julewire::Core::Fields::Internal::Deletion

Defined in:
lib/julewire/core/fields/internal/deletion.rb

Class Method Summary collapse

Class Method Details

.apply_delete_paths!(target, paths) ⇒ Object



17
18
19
20
# File 'lib/julewire/core/fields/internal/deletion.rb', line 17

def apply_delete_paths!(target, paths)
  paths.each { delete_path!(target, it) }
  target
end

.clear_delete_paths!(paths, fields) ⇒ Object



22
23
24
25
26
27
# File 'lib/julewire/core/fields/internal/deletion.rb', line 22

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
15
# 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)
  target
end

.normalize_path(path) ⇒ Object



29
30
31
# File 'lib/julewire/core/fields/internal/deletion.rb', line 29

def normalize_path(path)
  Array(path).flatten.filter_map { Internal.normalize_key(it) }
end