Enable passing include_links and include_relationship_links to serializer instances#735
Conversation
|
@mecampbellsoup Did you mean to close this? |
|
@lgebhardt woops! Sorrry 😄 |
|
@mecampbellsoup In the I think this will work: def initialize(primary_resource_klass, options = {})
@primary_class_name = primary_resource_klass._type
@fields = options.fetch(:fields, {})
@include = options.fetch(:include, [])
@include_directives = options[:include_directives]
@key_formatter = options.fetch(:key_formatter, JSONAPI.configuration.key_formatter)
@id_formatter = ValueFormatter.value_formatter_for(:id)
@link_builder = generate_link_builder(primary_resource_klass, options)
@always_include_to_one_linkage_data = options.fetch(:always_include_to_one_linkage_data,
JSONAPI.configuration.always_include_to_one_linkage_data)
@always_include_to_many_linkage_data = options.fetch(:always_include_to_many_linkage_data,
JSONAPI.configuration.always_include_to_many_linkage_data)
@serialization_options = options.fetch(:serialization_options, {})
@include_links = @serialization_options.fetch(:include_links, [])
@include_relationship_links = @serialization_options.fetch(:include_relationship_links, [])
# Warning: This makes ResourceSerializer non-thread-safe. That's not a problem with the
# request-specific way it's currently used, though.
@value_formatter_type_cache = NaiveCache.new{|arg| ValueFormatter.value_formatter_for(arg) }
endThen these options can be added to a controller through the |
|
@lgebhardt okay I will work on this. By two options, you're referring to |
|
https://github.com/cerebris/jsonapi-resources/issues/444#issuecomment-257076422 |
No description provided.