Skip to content

Commit

Permalink
Merge pull request #1320 from cerebris/default_processor_klass_deprec…
Browse files Browse the repository at this point in the history
…ation

Set default processor cass by name, deprecate default_processor_klass
  • Loading branch information
lgebhardt authored Apr 5, 2020
2 parents 879d5da + c73ab0b commit 7b64a08
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/jsonapi/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Configuration
:default_paginator,
:default_page_size,
:maximum_page_size,
:default_processor_klass,
:default_processor_klass_name,
:use_text_errors,
:top_level_links_include_pagination,
:top_level_meta_include_record_count,
Expand Down Expand Up @@ -110,7 +110,7 @@ def initialize

# The default Operation Processor to use if one is not defined specifically
# for a Resource.
self.default_processor_klass = JSONAPI::Processor
self.default_processor_klass_name = 'JSONAPI::Processor'

# Allows transactions for creating and updating records
# Set this to false if your backend does not support transactions (e.g. Mongodb)
Expand Down Expand Up @@ -225,9 +225,19 @@ def exception_class_whitelisted?(e)
end

def default_processor_klass=(default_processor_klass)
ActiveSupport::Deprecation.warn('`default_processor_klass` has been replaced by `default_processor_klass_name`.')
@default_processor_klass = default_processor_klass
end

def default_processor_klass
@default_processor_klass ||= default_processor_klass_name.safe_constantize
end

def default_processor_klass_name=(default_processor_klass_name)
@default_processor_klass = nil
@default_processor_klass_name = default_processor_klass_name
end

def allow_include=(allow_include)
ActiveSupport::Deprecation.warn('`allow_include` has been replaced by `default_allow_include_to_one` and `default_allow_include_to_many` options.')
@default_allow_include_to_one = allow_include
Expand Down

0 comments on commit 7b64a08

Please sign in to comment.