class Arborist::Node::Root

The class of the root node of an Arborist tree. This class is a Singleton.

Public Class Methods

instance( * ) click to toggle source

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
new( * ) click to toggle source

Create the instance of the Root node (if necessary) and return it.

Calls superclass method Arborist::Node::new
# File lib/arborist/node/root.rb, line 16
def self::new( * )
        @instance ||= super
        return @instance
end
new( * ) click to toggle source

Set up the root node.

Calls superclass method Arborist::Node::new
# File lib/arborist/node/root.rb, line 36
def initialize( * )
        super( '_' ) do
                description "The root node."
                self.source = URI( __FILE__ )
        end

        @status = 'up'
        @status.freeze
end
reset() click to toggle source

Reset the singleton instance; mainly used for testing.

# File lib/arborist/node/root.rb, line 30
def self::reset
        @instance = nil
end

Public Instance Methods

family() click to toggle source

Return the node family, so observers can know ancestry after serialization for custom node types that inherit from this class.

# File lib/arborist/node/root.rb, line 49
def family
        return :root
end
on_node_enabled( transition ) click to toggle source

Callback for when a node goes from disabled to unknown. Override, so we immediately transition from unknown to up.

Calls superclass method Arborist::Node#on_node_enabled
# File lib/arborist/node/root.rb, line 68
def on_node_enabled( transition )
        super
        events = self.update( {} ) # up!
        self.publish_events( events )
end
parent( * ) click to toggle source

Override the reader mode of Node#parent for the root node, which never has a parent.

# File lib/arborist/node/root.rb, line 77
def parent( * )
        return nil
end
restore( other_node ) click to toggle source

Ignore restores of serialized root nodes.

# File lib/arborist/node/root.rb, line 55
def restore( other_node )
        self.log.info "Ignoring restored root node."
end
update( properties, monitor_key='_' ) click to toggle source

Don't allow properties to be set on the root node.

Calls superclass method Arborist::Node#update
# File lib/arborist/node/root.rb, line 61
def update( properties, monitor_key='_' )
        return super( {} )
end