root key format

This commit is contained in:
Kyle Fritz
2014-04-14 13:45:12 -04:00
parent 00c54baae3
commit 76c8de7b9f
6 changed files with 32 additions and 17 deletions

View File

@@ -117,14 +117,16 @@ end
@except = Array(options[:except]) if options[:except]
@key_format = options[:key_format]
end
attr_accessor :object, :scope, :root, :meta_key, :meta
attr_accessor :object, :scope, :root, :meta_key, :meta, :key_format
def json_key
if root == true || root.nil?
key = if root == true || root.nil?
self.class.root_name
else
root
end
key_format == :lower_camel ? key.camelize(:lower) : key
end
def attributes