Permalink
Browse files

Adds include_child_root to readme and update changes

  • Loading branch information...
nesquena committed Jun 4, 2012
1 parent e22a1ab commit 0cc20c695cffa1fc372add179f3af6fee67ba657
Showing with 11 additions and 6 deletions.
  1. +3 −2 CHANGELOG.md
  2. +7 −3 README.md
  3. +1 −1 lib/rabl/engine.rb
View
@@ -1,8 +1,9 @@
# CHANGELOG
-## 0.6.13 (Unreleased)
+## 0.6.13
- * Small tweak to is_collection detection (look for each and map)
+ * Small tweak to is_collection detection (look for each and map)
+ * Adds `include_child_root` configuration option (Thanks @yoon)
## 0.6.12
View
@@ -110,16 +110,20 @@ Rabl.configure do |config|
# config.include_msgpack_root = true
# config.include_bson_root = true
# config.include_plist_root = true
- # config.include_xml_root = false
+ # config.include_xml_root = false
+ # config.include_child_root = true
# config.enable_json_callbacks = false
# config.xml_options = { :dasherize => true, :skip_types => false }
# config.view_paths = []
end
```
Each option specifies behavior related to RABL's output. If `include_json_root` is disabled that removes the
-root node for each child in the output, and `enable_json_callbacks` enables support for 'jsonp' style callback
-output if the incoming request has a 'callback' parameter.
+root node for each root object in the output, and `enable_json_callbacks` enables support for 'jsonp' style callback
+output if the incoming request has a 'callback' parameter.
+
+If `include_child_root` is set to false then child objects in the response will not include
+a root node by default. This allows you to further fine-tune your desired response structure.
If `cache_sources` is set to `true`, template lookups will be cached for improved performance.
The cache can be reset manually by running `Rabl.reset_source_cache!` within your application.
View
@@ -85,7 +85,7 @@ def to_plist(options={})
# to_xml(:root => true)
def to_xml(options={})
include_root = Rabl.configuration.include_xml_root
- include_child_root = Rabl.configuration.include_child_root
+ include_child_root = include_root && Rabl.configuration.include_child_root
options = options.reverse_merge(:root => include_root, :child_root => include_child_root)
xml_options = Rabl.configuration.default_xml_options.merge(:root => data_name(@_data))
to_hash(options).to_xml(xml_options)

0 comments on commit 0cc20c6

Please sign in to comment.