@@ -316,11 +316,22 @@ def add_show_related_resources_operation(association_type)
316316 )
317317 end
318318
319+ # TODO: Please remove after `createable_fields` is removed
320+ # :nocov:
321+ def creatable_fields
322+ if @resource_klass . respond_to? ( :createable_fields )
323+ creatable_fields = @resource_klass . createable_fields ( @context )
324+ else
325+ creatable_fields = @resource_klass . creatable_fields ( @context )
326+ end
327+ end
328+ # :nocov:
329+
319330 def parse_add_operation ( data )
320331 Array . wrap ( data ) . each do |params |
321332 verify_type ( params [ :type ] )
322333
323- data = parse_params ( params , @resource_klass . createable_fields ( @context ) )
334+ data = parse_params ( params , creatable_fields )
324335 @operations . push JSONAPI ::CreateResourceOperation . new (
325336 @resource_klass ,
326337 {
@@ -486,12 +497,23 @@ def verify_permitted_params(params, allowed_fields)
486497 raise JSONAPI ::Exceptions ::ParametersNotAllowed . new ( params_not_allowed ) if params_not_allowed . length > 0
487498 end
488499
500+ # TODO: Please remove after `updateable_fields` is removed
501+ # :nocov:
502+ def updatable_fields
503+ if @resource_klass . respond_to? ( :updateable_fields )
504+ @resource_klass . updateable_fields ( @context )
505+ else
506+ @resource_klass . updatable_fields ( @context )
507+ end
508+ end
509+ # :nocov:
510+
489511 def parse_add_association_operation ( data , association_type , parent_key )
490512 association = resource_klass . _association ( association_type )
491513
492514 if association . is_a? ( JSONAPI ::Association ::HasMany )
493515 object_params = { relationships : { format_key ( association . name ) => { data : data } } }
494- verified_param_set = parse_params ( object_params , @resource_klass . updateable_fields ( @context ) )
516+ verified_param_set = parse_params ( object_params , updatable_fields )
495517
496518 @operations . push JSONAPI ::CreateHasManyAssociationOperation . new (
497519 resource_klass ,
@@ -509,8 +531,7 @@ def parse_update_association_operation(data, association_type, parent_key)
509531
510532 if association . is_a? ( JSONAPI ::Association ::HasOne )
511533 object_params = { relationships : { format_key ( association . name ) => { data : data } } }
512-
513- verified_param_set = parse_params ( object_params , @resource_klass . updateable_fields ( @context ) )
534+ verified_param_set = parse_params ( object_params , updatable_fields )
514535
515536 @operations . push JSONAPI ::ReplaceHasOneAssociationOperation . new (
516537 resource_klass ,
@@ -526,7 +547,7 @@ def parse_update_association_operation(data, association_type, parent_key)
526547 end
527548
528549 object_params = { relationships : { format_key ( association . name ) => { data : data } } }
529- verified_param_set = parse_params ( object_params , @resource_klass . updateable_fields ( @context ) )
550+ verified_param_set = parse_params ( object_params , updatable_fields )
530551
531552 @operations . push JSONAPI ::ReplaceHasManyAssociationOperation . new (
532553 resource_klass ,
@@ -564,7 +585,7 @@ def parse_single_replace_operation(data, keys)
564585 @resource_klass ,
565586 {
566587 resource_id : key ,
567- data : parse_params ( data , @resource_klass . updateable_fields ( @context ) )
588+ data : parse_params ( data , updatable_fields )
568589 }
569590 )
570591 end
0 commit comments