Add support for meta key

Test for meta_key serialization
This commit is contained in:
tchak
2012-10-13 00:55:55 +02:00
parent 6b88f1b6ef
commit a71698d5bb
3 changed files with 65 additions and 0 deletions

View File

@@ -227,6 +227,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={})
@@ -235,6 +243,7 @@ module ActiveModel
@options[:unique_values] = {}
hash.merge!(root => serializable_hash)
include_meta hash
hash
else
serializable_hash