mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Merge pull request #1426 from brigade/default-include
Add a default_include_tree config variable to ActiveModel::Serializer
This commit is contained in:
@@ -10,8 +10,6 @@ module ActiveModel
|
||||
module Associations
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
DEFAULT_INCLUDE_TREE = ActiveModel::Serializer::IncludeTree.from_string('*')
|
||||
|
||||
included do
|
||||
with_options instance_writer: false, instance_reader: true do |serializer|
|
||||
serializer.class_attribute :_reflections
|
||||
@@ -80,10 +78,11 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
|
||||
# @param [IncludeTree] include_tree (defaults to all associations when not provided)
|
||||
# @param [IncludeTree] include_tree (defaults to the
|
||||
# default_includes config value when not provided)
|
||||
# @return [Enumerator<Association>]
|
||||
#
|
||||
def associations(include_tree = DEFAULT_INCLUDE_TREE)
|
||||
def associations(include_tree = ActiveModelSerializers.default_include_tree)
|
||||
return unless object
|
||||
|
||||
Enumerator.new do |y|
|
||||
|
||||
@@ -19,6 +19,7 @@ module ActiveModel
|
||||
collection_serializer
|
||||
end
|
||||
|
||||
config.default_includes = '*'
|
||||
config.adapter = :attributes
|
||||
config.jsonapi_resource_type = :plural
|
||||
config.jsonapi_version = '1.0'
|
||||
|
||||
Reference in New Issue
Block a user