Skip to content

Commit 3b3fc6d

Browse files
committed
Merge pull request #288 from ASnow/master
Add example for `merge!` to README.md
2 parents 0dce136 + e1f2099 commit 3b3fc6d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,19 @@ end
6767
# => {"author": { "name": "David" }}
6868
```
6969

70+
71+
To merge existing hash or array to current context:
72+
73+
``` ruby
74+
hash = { author: { name: "David" } }
75+
json.post do
76+
json.title "Merge HOWTO"
77+
json.merge! hash
78+
end
79+
80+
# => "post": { "title": "Merge HOWTO", "author": { "name": "David" } }
81+
```
82+
7083
Top level arrays can be handled directly. Useful for index and other collection actions.
7184

7285
``` ruby

0 commit comments

Comments
 (0)