mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Allow using root = false in initialize
This commit is contained in:
@@ -15,7 +15,8 @@ module ActiveModel
|
||||
def initialize(object, options={})
|
||||
@object = object
|
||||
@options = options
|
||||
@root = options[:root] || self.class._root
|
||||
@root = options[:root]
|
||||
@root = self.class._root if @root.nil?
|
||||
@meta_key = options[:meta_key] || :meta
|
||||
@meta = options[@meta_key]
|
||||
end
|
||||
|
||||
@@ -85,7 +85,8 @@ module ActiveModel
|
||||
alias read_attribute_for_serialization send
|
||||
|
||||
def root=(root)
|
||||
@root = root || self.class._root
|
||||
@root = root
|
||||
@root = self.class._root if @root.nil?
|
||||
@root = self.class.root_name if auto_assign_root?
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user