@@ -380,7 +380,7 @@ def serializable_hash(adapter_options = nil, options = {}, adapter_instance = se
380380 adapter_options ||= { }
381381 options [ :include_directive ] ||= ActiveModel ::Serializer . include_directive_from_options ( adapter_options )
382382 resource = attributes_hash ( adapter_options , options , adapter_instance )
383- relationships = resource_relationships ( adapter_options , options , adapter_instance )
383+ relationships = associations_hash ( adapter_options , options , adapter_instance )
384384 resource . merge ( relationships )
385385 end
386386 alias to_hash serializable_hash
@@ -423,34 +423,17 @@ def attributes_hash(_adapter_options, options, adapter_instance)
423423 end
424424
425425 # @api private
426- def resource_relationships ( adapter_options , options , adapter_instance )
426+ def associations_hash ( adapter_options , options , adapter_instance )
427427 relationships = { }
428428 include_directive = options . fetch ( :include_directive )
429429 associations ( include_directive ) . each do |association |
430430 adapter_opts = adapter_options . merge ( include_directive : include_directive [ association . key ] )
431- relationships [ association . key ] ||= relationship_value_for ( association , adapter_opts , adapter_instance )
431+ relationships [ association . key ] ||= association . serializable_hash ( adapter_opts , adapter_instance )
432432 end
433433
434434 relationships
435435 end
436436
437- # @api private
438- def relationship_value_for ( association , adapter_options , adapter_instance )
439- return association . options [ :virtual_value ] if association . options [ :virtual_value ]
440- association_serializer = association . serializer
441- association_object = association_serializer && association_serializer . object
442- return unless association_object
443-
444- relationship_value = association_serializer . serializable_hash ( adapter_options , { } , adapter_instance )
445-
446- if association . options [ :polymorphic ] && relationship_value
447- polymorphic_type = association_object . class . name . underscore
448- relationship_value = { type : polymorphic_type , polymorphic_type . to_sym => relationship_value }
449- end
450-
451- relationship_value
452- end
453-
454437 protected
455438
456439 attr_accessor :instance_options
0 commit comments