Class: Bcome::Registry::CommandList
- Inherits:
-
Object
- Object
- Bcome::Registry::CommandList
- Includes:
- Singleton
- Defined in:
- lib/objects/registry/command_list.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
Instance Method Summary collapse
- #add_group_for_node(node, group) ⇒ Object
- #command_in_list?(node, command_name) ⇒ Boolean
- #group_for_node(node) ⇒ Object
-
#initialize ⇒ CommandList
constructor
A new instance of CommandList.
- #register(node, command_name) ⇒ Object
- #teardown! ⇒ Object
Constructor Details
#initialize ⇒ CommandList
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
#list ⇒ Object (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
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 |