File tree Expand file tree Collapse file tree 1 file changed +9
-17
lines changed
Expand file tree Collapse file tree 1 file changed +9
-17
lines changed Original file line number Diff line number Diff line change @@ -541,27 +541,19 @@ def rebuild_relationships(relationships)
541541 end
542542
543543 def resource_klass_for ( type )
544+ @_resource_type_to_class_cache ||= { }
544545 type = type . underscore
545546
546- if ::Rails . application . config . cache_classes
547- @_resource_type_to_class_cache ||= { }
548- @_resource_type_to_class_cache . fetch ( type ) do
549- @_resource_type_to_class_cache [ type ] = _resource_klass_for ( type )
550- end
551- else
552- _resource_klass_for ( type )
553- end
554- end
555-
556- def _resource_klass_for ( type )
557- type_with_module = type . start_with? ( module_path ) ? type : module_path + type
547+ @_resource_type_to_class_cache . fetch ( type ) do
548+ type_with_module = type . start_with? ( module_path ) ? type : module_path + type
558549
559- resource_name = _resource_name_from_type ( type_with_module )
560- resource_klass = resource_name . safe_constantize if resource_name
561- if resource_klass . nil?
562- fail NameError , "JSONAPI: Could not find resource '#{ type } '. (Class #{ resource_name } not found)"
550+ resource_name = _resource_name_from_type ( type_with_module )
551+ resource_klass = resource_name . safe_constantize if resource_name
552+ if resource_klass . nil?
553+ fail NameError , "JSONAPI: Could not find resource '#{ type } '. (Class #{ resource_name } not found)"
554+ end
555+ @_resource_type_to_class_cache [ type ] = resource_klass
563556 end
564- resource_klass
565557 end
566558
567559 def resource_klass_for_model ( model )
You can’t perform that action at this time.
0 commit comments