Class: Arborist::Node::Root
- Inherits:
-
Arborist::Node
- Object
- Arborist::Node
- Arborist::Node::Root
- Extended by:
- MethodUtilities
- Defined in:
- lib/arborist/node/root.rb
Overview
The class of the root node of an Arborist tree. This class is a Singleton.
Constant Summary
Constants inherited from Arborist::Node
LOADED_INSTANCE_KEY, OPERATIONAL_ATTRIBUTES, UNREACHABLE_STATES, VALID_IDENTIFIER
Instance Attribute Summary
Attributes inherited from Arborist::Node
#ack, #children, #dependencies, #errors, #identifier, #last_contacted, #pending_change_events, #previous_ack, #properties, #quieted_reasons, #source, #status_changed, #status_history, #status_last_changed, #subscriptions, #update_delta, #warnings
Class Method Summary collapse
-
.instance ⇒ Object
Override the default constructor to use the singleton ::instance instead.
-
.new ⇒ Object
Create the instance of the Root node (if necessary) and return it.
-
.reset ⇒ Object
Reset the singleton instance; mainly used for testing.
Instance Method Summary collapse
-
#family ⇒ Object
Return the node family, so observers can know ancestry after serialization for custom node types that inherit from this class.
-
#initialize ⇒ Root
constructor
Set up the root node.
-
#on_node_enabled(transition) ⇒ Object
Callback for when a node goes from disabled to unknown.
-
#parent ⇒ Object
Override the reader mode of Node#parent for the root node, which never has a parent.
-
#restore(other_node) ⇒ Object
Ignore restores of serialized root nodes.
-
#update(properties, monitor_key = '_') ⇒ Object
Don’t allow properties to be set on the root node.
Methods included from MethodUtilities
attr_predicate, attr_predicate_accessor, dsl_accessor, singleton_attr_accessor, singleton_attr_reader, singleton_attr_writer, singleton_method_alias, singleton_predicate_accessor, singleton_predicate_reader
Methods inherited from Arborist::Node
#<<, #==, #acked_description, #acknowledge, #add_child, add_loaded_instance, add_subnode_factory_method, #add_subscription, #all_of, #any_of, #broadcast_events, #clear_transition_temp_vars, #config, curried_create, #dependencies_down?, #dependencies_up?, #depends_on, #description, #each, each_in, #fetch_values, #find_matching_subscriptions, #flap_threshold, #flapping, from_hash, #handle_event, #handle_node_disabled_event, #handle_node_down_event, #handle_node_quieted_event, #handle_node_up_event, #has_children?, #has_dependencies?, #has_quieted_reason?, inherited, #inspect, load, #make_delta_event, #make_update_event, #marshal_dump, #marshal_load, #match_criteria?, #matches?, #merge_and_record_delta, #merge_new_properties, #modify, #node_description, #node_subscribers, #operational?, #operational_values, parent_types, #publish_events, #reachable?, #register_secondary_dependencies, #remove_child, #remove_subscription, #reparent, #state_has_changed?, #status, #status_description, #status_history_size, subnode_type?, #tags, #to_h, #type, #unacknowledge, #unreachable?, #update_errors, #update_properties, #update_warnings
Methods included from HashUtilities
compact_hash, hash_matches, merge_recursively, stringify_keys, symbolify_keys
Constructor Details
#initialize ⇒ Root
Set up the root node.
37 38 39 40 41 42 43 44 45 |
# File 'lib/arborist/node/root.rb', line 37 def initialize( * ) super( '_' ) do description "The root node." self.source = URI( __FILE__ ) end @status = 'up' @status.freeze end |
Class Method Details
.instance ⇒ Object
Override the default constructor to use the singleton ::instance instead.
24 25 26 27 |
# File 'lib/arborist/node/root.rb', line 24 def self::instance( * ) @instance ||= new return @instance end |
.new ⇒ Object
Create the instance of the Root node (if necessary) and return it.
17 18 19 20 |
# File 'lib/arborist/node/root.rb', line 17 def self::new( * ) @instance ||= super return @instance end |
.reset ⇒ Object
Reset the singleton instance; mainly used for testing.
31 32 33 |
# File 'lib/arborist/node/root.rb', line 31 def self::reset @instance = nil end |
Instance Method Details
#family ⇒ Object
Return the node family, so observers can know ancestry after serialization for custom node types that inherit from this class.
50 51 52 |
# File 'lib/arborist/node/root.rb', line 50 def family return :root end |
#on_node_enabled(transition) ⇒ Object
Callback for when a node goes from disabled to unknown. Override, so we immediately transition from unknown to up.
69 70 71 72 73 |
# File 'lib/arborist/node/root.rb', line 69 def on_node_enabled( transition ) super events = self.update( {} ) # up! self.publish_events( events ) end |
#parent ⇒ Object
Override the reader mode of Node#parent for the root node, which never has a parent.
78 79 80 |
# File 'lib/arborist/node/root.rb', line 78 def parent( * ) return nil end |
#restore(other_node) ⇒ Object
Ignore restores of serialized root nodes.
56 57 58 |
# File 'lib/arborist/node/root.rb', line 56 def restore( other_node ) self.log.info "Ignoring restored root node." end |
#update(properties, monitor_key = '_') ⇒ Object
Don’t allow properties to be set on the root node.
62 63 64 |
# File 'lib/arborist/node/root.rb', line 62 def update( properties, monitor_key='_' ) return super( {} ) end |