Skip to content

Commit e1f2099

Browse files
ASnowpixeltrix
authored andcommitted
Add example for merge! to README.md
1 parent 0dce136 commit e1f2099

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)