File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -353,16 +353,12 @@ def related_link(source, relationship)
353353 end
354354
355355 def to_one_linkage ( source , relationship )
356- linkage = { }
357- linkage_id = foreign_key_value ( source , relationship )
358-
359- if linkage_id
360- linkage [ :type ] = format_key ( relationship . type_for_source ( source ) )
361- linkage [ :id ] = linkage_id
362- else
363- linkage = nil
364- end
365- linkage
356+ return unless linkage_id = foreign_key_value ( source , relationship )
357+ return unless linkage_type = format_key ( relationship . type_for_source ( source ) )
358+ {
359+ type : linkage_type ,
360+ id : linkage_id ,
361+ }
366362 end
367363
368364 def to_many_linkage ( source , relationship )
@@ -390,7 +386,9 @@ def to_many_linkage(source, relationship)
390386 end
391387
392388 linkage_types_and_values . each do |type , value |
393- linkage . append ( { type : format_key ( type ) , id : @id_formatter . format ( value ) } )
389+ if type && value
390+ linkage . append ( { type : format_key ( type ) , id : @id_formatter . format ( value ) } )
391+ end
394392 end
395393 linkage
396394 end
You can’t perform that action at this time.
0 commit comments