Skip to content

Commit 4b2e0f7

Browse files
authored
Merge pull request #1268 from cerebris/resource_class_inheritance_tweaks
Fix issues with resource definition order and initializers.
2 parents 0072fef + 2efa6bd commit 4b2e0f7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/jsonapi/basic_resource.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,13 @@ def inherited(subclass)
422422
subclass.abstract(false)
423423
subclass.immutable(false)
424424
subclass.caching(_caching)
425+
subclass.cache_field(_cache_field) if @_cache_field
425426
subclass.singleton(singleton?, (_singleton_options.dup || {}))
426427
subclass.exclude_links(_exclude_links)
427-
subclass.paginator(_paginator)
428+
subclass.paginator(@_paginator)
428429
subclass._attributes = (_attributes || {}).dup
429430
subclass.polymorphic(false)
431+
subclass.key_type(@_resource_key_type)
430432

431433
subclass._model_hints = (_model_hints || {}).dup
432434

@@ -755,7 +757,7 @@ def key_type(key_type)
755757
end
756758

757759
def resource_key_type
758-
@_resource_key_type ||= JSONAPI.configuration.resource_key_type
760+
@_resource_key_type || JSONAPI.configuration.resource_key_type
759761
end
760762

761763
# override to all resolution of masked ids to actual ids. Because singleton routes do not specify the id this
@@ -878,7 +880,7 @@ def _default_primary_key
878880
end
879881

880882
def _cache_field
881-
@_cache_field ||= JSONAPI.configuration.default_resource_cache_field
883+
@_cache_field || JSONAPI.configuration.default_resource_cache_field
882884
end
883885

884886
def _table_name
@@ -898,7 +900,7 @@ def _allowed_sort
898900
end
899901

900902
def _paginator
901-
@_paginator ||= JSONAPI.configuration.default_paginator
903+
@_paginator || JSONAPI.configuration.default_paginator
902904
end
903905

904906
def paginator(paginator)

0 commit comments

Comments
 (0)