Skip to content

Commit b4c610b

Browse files
committed
Remove deprecated updateable and createable methods
1 parent 8a2bd30 commit b4c610b

File tree

3 files changed

+3
-54
lines changed

3 files changed

+3
-54
lines changed

lib/jsonapi/request_parser.rb

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def parse_modify_relationship_action(params, modification_type)
122122
if data_required
123123
data = params.fetch(:data)
124124
object_params = { relationships: { format_key(relationship.name) => { data: data } } }
125-
verified_params = parse_params(object_params, updatable_fields)
125+
verified_params = parse_params(object_params, @resource_klass.updatable_fields(@context))
126126

127127
parse_arguments = [verified_params, relationship, parent_key]
128128
else
@@ -346,22 +346,11 @@ def add_show_related_resources_operation(relationship_type)
346346
)
347347
end
348348

349-
# TODO: Please remove after `createable_fields` is removed
350-
# :nocov:
351-
def creatable_fields
352-
if @resource_klass.respond_to?(:createable_fields)
353-
creatable_fields = @resource_klass.createable_fields(@context)
354-
else
355-
creatable_fields = @resource_klass.creatable_fields(@context)
356-
end
357-
end
358-
# :nocov:
359-
360349
def parse_add_operation(data)
361350
Array.wrap(data).each do |params|
362351
verify_type(params[:type])
363352

364-
data = parse_params(params, creatable_fields)
353+
data = parse_params(params, @resource_klass.creatable_fields(@context))
365354
@operations.push JSONAPI::Operation.new(:create_resource,
366355
@resource_klass,
367356
context: @context,
@@ -567,17 +556,6 @@ def verify_permitted_params(params, allowed_fields)
567556
end
568557
end
569558

570-
# TODO: Please remove after `updateable_fields` is removed
571-
# :nocov:
572-
def updatable_fields
573-
if @resource_klass.respond_to?(:updateable_fields)
574-
@resource_klass.updateable_fields(@context)
575-
else
576-
@resource_klass.updatable_fields(@context)
577-
end
578-
end
579-
# :nocov:
580-
581559
def parse_add_relationship_operation(verified_params, relationship, parent_key)
582560
if relationship.is_a?(JSONAPI::Relationship::ToMany)
583561
@operations.push JSONAPI::Operation.new(:create_to_many_relationship,
@@ -634,7 +612,7 @@ def parse_single_replace_operation(data, keys, id_key_presence_check_required: t
634612
@resource_klass,
635613
context: @context,
636614
resource_id: key,
637-
data: parse_params(data, updatable_fields),
615+
data: parse_params(data, @resource_klass.updatable_fields(@context)),
638616
fields: @fields,
639617
include_directives: @include_directives
640618
)

lib/jsonapi/resource.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -572,21 +572,6 @@ def cache_field(field)
572572
@_cache_field = field.to_sym
573573
end
574574

575-
# TODO: remove this after the createable_fields and updateable_fields are phased out
576-
# :nocov:
577-
def method_missing(method, *args)
578-
if method.to_s.match(/createable_fields/)
579-
ActiveSupport::Deprecation.warn('`createable_fields` is deprecated, please use `creatable_fields` instead')
580-
creatable_fields(*args)
581-
elsif method.to_s.match(/updateable_fields/)
582-
ActiveSupport::Deprecation.warn('`updateable_fields` is deprecated, please use `updatable_fields` instead')
583-
updatable_fields(*args)
584-
else
585-
super
586-
end
587-
end
588-
# :nocov:
589-
590575
# Override in your resource to filter the updatable keys
591576
def updatable_fields(_context = nil)
592577
_updatable_relationships | _attributes.keys - [:id]

test/unit/resource/resource_test.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -286,20 +286,6 @@ def test_updatable_fields_does_not_include_id
286286
assert(!CatResource.updatable_fields.include?(:id))
287287
end
288288

289-
# TODO: Please remove after `updateable_fields` is removed
290-
def test_updateable_fields_delegates_to_updatable_fields_with_deprecation
291-
ActiveSupport::Deprecation.silence do
292-
assert_empty(CatResource.updateable_fields(nil) - [:mother, :father, :name, :breed, :kind])
293-
end
294-
end
295-
296-
# TODO: Please remove after `createable_fields` is removed
297-
def test_createable_fields_delegates_to_creatable_fields_with_deprecation
298-
ActiveSupport::Deprecation.silence do
299-
assert_empty(CatResource.createable_fields(nil) - [:mother, :father, :name, :breed, :id, :kind])
300-
end
301-
end
302-
303289
def test_filter_on_to_many_relationship_id
304290
posts = PostResource.find(:comments => 3)
305291
assert_equal([2], posts.map(&:id))

0 commit comments

Comments
 (0)