The class of the root node of an Arborist tree. This class is a Singleton.
Override the default constructor to use the singleton ::instance instead.
# File lib/arborist/node/root.rb, line 23
def self::instance( * )
@instance ||= new
return @instance
end
Set up the root node.
# File lib/arborist/node/root.rb, line 36
def initialize( * )
super( '_' ) do
description "The root node."
source = URI( __FILE__ )
end
@status = 'up'
@status.freeze
end
Create the instance of the Root node (if necessary) and return it.
# File lib/arborist/node/root.rb, line 16
def self::new( * )
@instance ||= super
return @instance
end
Reset the singleton instance; mainly used for testing.
# File lib/arborist/node/root.rb, line 30
def self::reset
@instance = nil
end
Callback for when a node goes from disabled to unknown. Override, so we immediately transition from unknown to up.
# File lib/arborist/node/root.rb, line 61
def on_node_enabled( transition )
super
events = self.update( {} ) # up!
self.publish_events( events )
end
Override the reader mode of Node#parent for the root node, which never has a parent.
# File lib/arborist/node/root.rb, line 70
def parent( * )
return nil
end
Ignore restores of serialized root nodes.
# File lib/arborist/node/root.rb, line 48
def restore( other_node )
self.log.info "Ignoring restored root node."
end
Don't allow properties to be set on the root node.
# File lib/arborist/node/root.rb, line 54
def update( properties, monitor_key='_' )
return super( {} )
end