Skip to content

Commit 90dae75

Browse files
etiennechabertEtienne Chabert
andauthored
Prevent warnings variable @metadata not initialised (#86)
* Use metadata method instead of @metadata variable * empty * Go back to @metadata, but with metadata before to ensure initialization * Update entity.rb * Update entity.rb --------- Co-authored-by: Etienne Chabert <[email protected]>
1 parent 5430136 commit 90dae75

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/aws-xray-sdk/model/entity.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ def to_h
155155
if (a = annotations.to_h) && !a.empty?
156156
h[:annotations] = a
157157
end
158-
if (m = @metadata) && !m.to_h.empty?
158+
# make sure @metadata is defined before evaluating it, to prevent warning `variable @metadata not initialized`
159+
if (defined?(@metadata) && m = @metadata) && !m.to_h.empty?
159160
h[:metadata] = m.to_h
160161
end
161162

0 commit comments

Comments
 (0)