mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
@@ -35,6 +35,14 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
|
||||
def meta_key
|
||||
@options[:meta_key].try(:to_sym) || :meta
|
||||
end
|
||||
|
||||
def include_meta(hash)
|
||||
hash[meta_key] = @options[:meta] if @options.has_key?(:meta)
|
||||
end
|
||||
|
||||
def as_json(*args)
|
||||
@options[:hash] = hash = {}
|
||||
@options[:unique_values] = {}
|
||||
@@ -49,6 +57,8 @@ module ActiveModel
|
||||
|
||||
if root = @options[:root]
|
||||
hash.merge!(root => array)
|
||||
include_meta hash
|
||||
hash
|
||||
else
|
||||
array
|
||||
end
|
||||
|
||||
@@ -242,6 +242,14 @@ module ActiveModel
|
||||
@options[:url_options] || {}
|
||||
end
|
||||
|
||||
def meta_key
|
||||
@options[:meta_key].try(:to_sym) || :meta
|
||||
end
|
||||
|
||||
def include_meta(hash)
|
||||
hash[meta_key] = @options[:meta] if @options.has_key?(:meta)
|
||||
end
|
||||
|
||||
# Returns a json representation of the serializable
|
||||
# object including the root.
|
||||
def as_json(options={})
|
||||
@@ -250,6 +258,7 @@ module ActiveModel
|
||||
@options[:unique_values] = {}
|
||||
|
||||
hash.merge!(root => serializable_hash)
|
||||
include_meta hash
|
||||
hash
|
||||
else
|
||||
serializable_hash
|
||||
|
||||
Reference in New Issue
Block a user