Class: Bcome::Node::Resources::Inventory

Inherits:
Base
  • Object
show all
Defined in:
lib/objects/node/resources/inventory.rb

Direct Known Subclasses

SubselectInventory

Instance Attribute Summary

Attributes inherited from Base

#nodes

Instance Method Summary collapse

Methods inherited from Base

#active, #clear!, #disable, #disable!, #do_disable, #do_enable, #each, #empty?, #enable, #enable!, #first, #for_identifier, #has_active_nodes?, #initialize, #is_active_resource?, #size

Constructor Details

This class inherits a constructor from Bcome::Node::Resources::Base

Instance Method Details

#<<(node) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/objects/node/resources/inventory.rb', line 3

def <<(node)
  if existing_node = for_identifier(node.identifier)
    if existing_node.static_server? && node.dynamic_server?
      # We've got a duplicate, but we'll treat the remote node as authoritative
      # We remove the static server from our selection
      @nodes.delete(existing_node)
    else
      exception_message = "#{node.identifier} is not unique within namespace #{node.parent.namespace}"
      raise Bcome::Exception::NodeIdentifiersMustBeUnique, exception_message
    end
  end
  @nodes << node
end

#dynamic_nodesObject



17
18
19
# File 'lib/objects/node/resources/inventory.rb', line 17

def dynamic_nodes
  active.select(&:dynamic_server?)
end

#unset!Object



21
22
23
# File 'lib/objects/node/resources/inventory.rb', line 21

def unset!
  @nodes = []
end