module FSSM::Tree::NodeInsertion

Public Instance Methods

set(path) click to toggle source
# File lib/fssm/tree.rb, line 66
def set(path)
  node = descendant!(path)
  node.from_path(path).mtime
end
unset(path) click to toggle source
# File lib/fssm/tree.rb, line 48
def unset(path)
  key = key_segments(path)

  if key.empty?
    remove_children
    return nil
  end

  segment = key.pop
  node    = descendant(key)

  return unless node

  node.remove_child(segment)

  nil
end

Protected Instance Methods

descendant(path) click to toggle source
# File lib/fssm/tree.rb, line 78
def descendant(path)
  recurse(path, false)
end
descendant!(path) click to toggle source
# File lib/fssm/tree.rb, line 82
def descendant!(path)
  recurse(path, true)
end
key_segments(key) click to toggle source
# File lib/fssm/tree.rb, line 73
def key_segments(key)
  return key if key.is_a?(Array)
  FSSM::Pathname.for(key).segments
end
recurse(key, create=false) click to toggle source
# File lib/fssm/tree.rb, line 86
def recurse(key, create=false)
  key  = key_segments(key)
  node = self

  until key.empty?
    segment = key.shift
    node    = create ? node.child!(segment) : node.child(segment)
    return nil unless node
  end

  node
end