Class: Bcome::Registry::CommandList

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/objects/registry/command_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommandList

Returns a new instance of CommandList.



7
8
9
10
# File 'lib/objects/registry/command_list.rb', line 7

def initialize
  @list = {}
  @groups_for_nodes = {}
end

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



5
6
7
# File 'lib/objects/registry/command_list.rb', line 5

def list
  @list
end

Instance Method Details

#add_group_for_node(node, group) ⇒ Object



12
13
14
# File 'lib/objects/registry/command_list.rb', line 12

def add_group_for_node(node, group)
  @groups_for_nodes[node.keyed_namespace] = group
end

#command_in_list?(node, command_name) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/objects/registry/command_list.rb', line 24

def command_in_list?(node, command_name)
  @list.key?(node.keyed_namespace) && @list[node.keyed_namespace].include?(command_name.to_sym)
end

#group_for_node(node) ⇒ Object



16
17
18
# File 'lib/objects/registry/command_list.rb', line 16

def group_for_node(node)
  @groups_for_nodes[node.keyed_namespace]
end

#register(node, command_name) ⇒ Object



20
21
22
# File 'lib/objects/registry/command_list.rb', line 20

def register(node, command_name)
  @list[node.keyed_namespace] ? (@list[node.keyed_namespace] << command_name) : (@list[node.keyed_namespace] = [command_name])
end

#teardown!Object



28
29
30
31
# File 'lib/objects/registry/command_list.rb', line 28

def teardown!
  @groups_for_nodes = {}
  @list = {}
end