@@ -50,51 +50,13 @@ module Athena::DependencyInjection::ServiceContainer::RegisterServices
5050 end
5151 % }
5252
53- {%
54- definition_tags = {} of Nil => Nil
55- tags = ann[" tags" ] || [] of Nil
53+ {% # Store raw tags - will be normalized by ProcessTags pass
5654
57- unless tags.is_a? ArrayLiteral
58- ann[" tags" ].raise " 'tags' field of service '#{ service_id.id } ' must be an 'ArrayLiteral', got '#{ tags.class_name.id } '."
59- end
55+ tags = ann[" tags" ] || [] of Nil
6056
61- # TODO: Centralize tag handling logic between AutoConfigure and RegisterServices
62- tags.each do |tag |
63- name, attributes = if tag.is_a?(StringLiteral )
64- {tag, {} of Nil => Nil }
65- elsif tag.is_a?(Path )
66- {tag.resolve.id.stringify, {} of Nil => Nil }
67- elsif tag.is_a?(NamedTupleLiteral ) || tag.is_a?(HashLiteral )
68- unless tag[:name ]
69- tag.raise " Failed to register service '#{ service_id.id } '. Tag must have a name."
70- end
71-
72- # Resolve a constant to its value if used as a tag name
73- if tag[" name" ].is_a? Path
74- tag[" name" ] = tag[" name" ].resolve
75- end
76-
77- attributes = {} of Nil => Nil
78-
79- # TODO: Replace this with `#delete`...
80- tag.each do |k , v |
81- attributes[k.id.stringify] = v unless k.id.stringify == " name"
82- end
83-
84- {tag[" name" ], attributes}
85- else
86- tag.raise " Tag must be a 'StringLiteral' or 'NamedTupleLiteral', got '#{ tag.class_name.id } '."
87- end
88-
89- definition_tags[name] = [] of Nil if definition_tags[name] == nil
90- definition_tags[name] << attributes
91- definition_tags[name] = definition_tags[name].uniq
92-
93- TAG_HASH [name] = [] of Nil if TAG_HASH [name] == nil
94- TAG_HASH [name] << {service_id, attributes}
95- TAG_HASH [name] = TAG_HASH [name].uniq
96- end
97- % }
57+ unless tags.is_a? ArrayLiteral
58+ ann[" tags" ].raise " 'tags' field of service '#{ service_id.id } ' must be an 'ArrayLiteral', got '#{ tags.class_name.id } '."
59+ end % }
9860
9961 # Generic services are somewhat coupled to the annotation, so do a check here in addition to those in `ResolveGenerics`.
10062 {%
@@ -138,8 +100,8 @@ module Athena::DependencyInjection::ServiceContainer::RegisterServices
138100 shared: klass.class?,
139101 calls: calls,
140102 configurator: nil ,
141- tags: definition_tags ,
142- public: ann[: public ] == true ,
103+ tags: tags ,
104+ public: ann[" public" ] == true ,
143105 decorated_service: nil ,
144106 bindings: {} of Nil => Nil ,
145107 generics: ann.args,
0 commit comments