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.



9
10
11
12
# File 'lib/objects/registry/command_list.rb', line 9

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

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



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

def list
  @list
end

Instance Method Details

#add_group_for_node(node, group) ⇒ Object



14
15
16
# File 'lib/objects/registry/command_list.rb', line 14

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

#command_in_list?(node, command_name) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/objects/registry/command_list.rb', line 26

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



18
19
20
# File 'lib/objects/registry/command_list.rb', line 18

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

#register(node, command_name) ⇒ Object



22
23
24
# File 'lib/objects/registry/command_list.rb', line 22

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

#teardown!Object



30
31
32
33
# File 'lib/objects/registry/command_list.rb', line 30

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