docs/root-elements.md in flexirest-1.10.2 vs docs/root-elements.md in flexirest-1.10.3
- old
+ new
@@ -1,19 +1,38 @@
# *Flexirest:* Root elements
If your response comes back with a root node and you'd like to ignore it, you can define the mapping as:
```ruby
+Flexirest::Base.ignore_root = "data"
+```
+
+Any `ignore_root` setting in specific class overrides this declared default.
+
+```ruby
class Feed < Flexirest::Base
- post :list, "/feed", ignore_root: "feed"
+ ignore_root: "feed"
+
+ post :list, "/feed"
end
```
-This also works if you'd want to remove a tree of root nodes:
+And any `ignore_root` setting in specific request overrides the both default and class specific setting.
+
```ruby
class Feed < Flexirest::Base
+ ignore_root: 'feed'
+
+ post :list, "/feed", ignore_root: "result"
+end
+```
+
+You can also assign an array to `ignore_root` if you'd want to remove a tree of root nodes.
+
+```ruby
+class Feed < Flexirest::Base
post :list, "/feed", ignore_root: ["feed", "items"]
end
```
Alternatively if you want to wrap your JSON request body in a root element, e.g.:
@@ -24,19 +43,35 @@
"id": 1
}
}
```
-You can do it like this:
+You can do it using `wrap_root`:
```ruby
+Flexirest::Base.wrap_root = "data"
+```
+
+Any `wrap_root` setting in specific class overrides this declared default.
+
+```ruby
class Feed < Flexirest::Base
- post :list, "/feed", wrap_root: "feed"
-end
+ wrap_root: "feed"
-Feed.list(id: 1)
+ post :list, "/feed"
+end
```
+And any `wrap_root` setting in specific request overrides the both default and class specific setting.
+
+
+```ruby
+class Feed < Flexirest::Base
+ wrap_root: 'feed'
+
+ post :list, "/feed", wrap_root: "data"
+end
+```
-----
[< Default parameters](default-parameters.md) | [Required parameters >](required-parameters.md)