Skip to content

Commit

Permalink
Rename resource_finder config option to default_resource_finder
Browse files Browse the repository at this point in the history
  • Loading branch information
lgebhardt committed Mar 7, 2019
1 parent 469d452 commit c50b1c5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/jsonapi/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Configuration
:default_paginator,
:default_page_size,
:maximum_page_size,
:resource_finder,
:default_resource_finder,
:default_processor_klass,
:use_text_errors,
:top_level_links_include_pagination,
Expand Down Expand Up @@ -109,7 +109,7 @@ def initialize
# The default ResourceFinder is the ActiveRelationResourceFinder which provides
# access to ActiveRelation backed models. Custom ResourceFinders can be specified
# in order to support other ORMs.
self.resource_finder = JSONAPI::ActiveRelationResourceFinder
self.default_resource_finder = JSONAPI::ActiveRelationResourceFinder

# The default Operation Processor to use if one is not defined specifically
# for a Resource.
Expand Down Expand Up @@ -225,8 +225,8 @@ def default_processor_klass=(default_processor_klass)
@default_processor_klass = default_processor_klass
end

def resource_finder=(resource_finder)
@resource_finder = resource_finder
def default_resource_finder=(default_resource_finder)
@default_resource_finder = default_resource_finder
end

def allow_include=(allow_include)
Expand Down
2 changes: 1 addition & 1 deletion lib/jsonapi/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def inherited(subclass)

check_reserved_resource_name(subclass._type, subclass.name)

subclass.include JSONAPI.configuration.resource_finder if JSONAPI.configuration.resource_finder
subclass.include JSONAPI.configuration.default_resource_finder if JSONAPI.configuration.default_resource_finder
end

# A ResourceFinder is a mixin that adds functionality to find Resources and Resource Fragments
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,7 @@ def find_breeds_by_keys(keys, options = {})
end
end

JSONAPI.configuration.resource_finder = BreedResourceFinder
JSONAPI.configuration.default_resource_finder = BreedResourceFinder
class BreedResource < JSONAPI::Resource
attribute :name, format: :title

Expand All @@ -1569,7 +1569,7 @@ def _save
return :accepted
end
end
JSONAPI.configuration.resource_finder = JSONAPI::ActiveRelationResourceFinder
JSONAPI.configuration.default_resource_finder = JSONAPI::ActiveRelationResourceFinder

class PlanetResource < JSONAPI::Resource
attribute :name
Expand Down

0 comments on commit c50b1c5

Please sign in to comment.