File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -247,24 +247,22 @@ def related_link(source, relationship)
247247 end
248248
249249 def to_one_linkage ( source , relationship )
250- linkage = { }
251- linkage_id = foreign_key_value ( source , relationship )
252-
253- if linkage_id
254- linkage [ :type ] = format_key ( relationship . type_for_source ( source ) )
255- linkage [ :id ] = linkage_id
256- else
257- linkage = nil
258- end
259- linkage
250+ return unless linkage_id = foreign_key_value ( source , relationship )
251+ return unless linkage_type = format_key ( relationship . type_for_source ( source ) )
252+ {
253+ type : linkage_type ,
254+ id : linkage_id ,
255+ }
260256 end
261257
262258 def to_many_linkage ( source , relationship )
263259 linkage = [ ]
264260 linkage_types_and_values = foreign_key_types_and_values ( source , relationship )
265261
266262 linkage_types_and_values . each do |type , value |
267- linkage . append ( { type : format_key ( type ) , id : value } )
263+ if type && value
264+ linkage . append ( { type : format_key ( type ) , id : @id_formatter . format ( value ) } )
265+ end
268266 end
269267 linkage
270268 end
You can’t perform that action at this time.
0 commit comments