Permalink
Browse files

passing in object to child and glue examples

  • Loading branch information...
1 parent 546bb1e commit 642bb60d8f5d3881fd262b361d1ff195f8a061cf @databyte databyte committed Aug 6, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 README.md
View
@@ -277,6 +277,15 @@ child :posts => :foobar do
end
```
+You can also pass in the current object:
+
+```ruby
+object @user
+child :posts do |user|
+ attribute :title unless user.suspended?
+end
+```
+
### Gluing Attributes ###
You can also append child attributes back to the root node:
@@ -290,6 +299,13 @@ end
Use glue to add additional attributes to the parent object.
+You can also pass in the current object:
+
+```ruby
+object @user
+glue(@post) {|user| attribute :title if user.active? }
+```
+
### Custom Nodes ###
This will generate a json response based on the result of the `node` block:

0 comments on commit 642bb60

Please sign in to comment.