mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Deprecate include in favor of side_load
This commit is contained in:
@@ -19,14 +19,14 @@ module ActiveModel
|
||||
|
||||
def embed(type, options={})
|
||||
CONFIG.embed = type
|
||||
CONFIG.include = true if options[:include]
|
||||
CONFIG.side_load = true if options[:side_load] || options[:include]
|
||||
ActiveSupport::Deprecation.warn <<-WARN
|
||||
** Notice: embed is deprecated. **
|
||||
The use of .embed method on a Serializer will be soon removed, as this should have a global scope and not a class scope.
|
||||
Please use the global .setup method instead:
|
||||
ActiveModel::Serializer.setup do |config|
|
||||
config.embed = :#{type}
|
||||
config.include = #{CONFIG.include || false}
|
||||
config.side_load = #{CONFIG.side_load || false}
|
||||
end
|
||||
WARN
|
||||
end
|
||||
|
||||
@@ -5,10 +5,16 @@ module ActiveModel
|
||||
class Serializer
|
||||
class Association
|
||||
def initialize(name, options={})
|
||||
if options.has_key?(:include)
|
||||
ActiveSupport::Deprecation.warn <<-WARN
|
||||
** Notice: include was renamed to side_load. **
|
||||
WARN
|
||||
end
|
||||
|
||||
@name = name.to_s
|
||||
@options = options
|
||||
self.embed = options.fetch(:embed) { CONFIG.embed }
|
||||
@side_load = options.fetch(:include) { CONFIG.include }
|
||||
@side_load = options.fetch(:side_load) { options.fetch(:include) { CONFIG.side_load } }
|
||||
@embed_key = options[:embed_key] || :id
|
||||
@key = options[:key]
|
||||
@embedded_key = options[:root] || name
|
||||
|
||||
Reference in New Issue
Block a user