Class: Minitag::TagRegistry
- Inherits:
-
Object
- Object
- Minitag::TagRegistry
- Defined in:
- lib/minitag/tag_registry.rb
Overview
Stores tags associated with a namespace or a single test case.
A namespace is usually the class which tests belongs to.
Instance Method Summary collapse
-
#add(namespace:, name:, tags:) ⇒ void
Associates tags with a name taking into account its namespace.
-
#add_for_namespace(namespace:, tags:) ⇒ void
Associates tags with a namespace.
-
#get(namespace:, name:) ⇒ Set
Fetches tags associated with a test name and namespace.
-
#initialize ⇒ TagRegistry
constructor
A new instance of TagRegistry.
Constructor Details
#initialize ⇒ TagRegistry
Returns a new instance of TagRegistry.
8 9 10 |
# File 'lib/minitag/tag_registry.rb', line 8 def initialize @registry = {} end |
Instance Method Details
#add(namespace:, name:, tags:) ⇒ void
This method returns an undefined value.
Associates tags with a name taking into account its namespace.
Duplicated tags will be removed during this operation.
21 22 23 |
# File 'lib/minitag/tag_registry.rb', line 21 def add(namespace:, name:, tags:) @registry[key(namespace, name)] = Set.new() end |
#add_for_namespace(namespace:, tags:) ⇒ void
This method returns an undefined value.
Associates tags with a namespace.
Duplicated tags will be removed during this operation.
33 34 35 |
# File 'lib/minitag/tag_registry.rb', line 33 def add_for_namespace(namespace:, tags:) @registry[namespace] = Set.new() end |
#get(namespace:, name:) ⇒ Set
Fetches tags associated with a test name and namespace.
43 44 45 46 47 |
# File 'lib/minitag/tag_registry.rb', line 43 def get(namespace:, name:) @registry.fetch(namespace, Set.new).union( @registry.fetch(key(namespace, name), Set.new) ) end |