Skip to content

Commit 00b2961

Browse files
committedFeb 11, 2021
Simplify create_annotations.
1 parent ba20d10 commit 00b2961

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

Diff for: ‎lib/json/ld/flatten.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,9 @@ def create_annotations(node_map)
210210
sort_by(&:length).
211211
reverse.each do |key|
212212

213+
annotation = node_map[key]
213214
# Deserialize key, and re-serialize the `@id` value.
214-
emb = JSON.parse(key)
215+
emb = annotation['@id'].dup
215216
id = emb.delete('@id')
216217
property, value = emb.to_a.first
217218

@@ -227,7 +228,7 @@ def create_annotations(node_map)
227228
node[property].each do |emb_value|
228229
next unless emb_value == value.first
229230

230-
annotation = node_map.delete(key)
231+
node_map.delete(key)
231232
annotation.delete('@id')
232233
add_value(emb_value, '@annotation', annotation, property_is_array: true) unless
233234
annotation.empty?

0 commit comments

Comments
 (0)
Please sign in to comment.