@@ -1,14 +1,29 | |||||
1 | module ObjectDaddyHelpers |
|
1 | module ObjectDaddyHelpers | |
2 | # TODO: The gem or official version of ObjectDaddy doesn't set |
|
2 | # TODO: The gem or official version of ObjectDaddy doesn't set | |
3 | # protected attributes so they need to be wrapped. |
|
3 | # protected attributes so they need to be wrapped. | |
|
4 | def User.generate_with_protected(attributes={}) | |||
|
5 | user = User.spawn_with_protected(attributes) | |||
|
6 | user.save | |||
|
7 | user | |||
|
8 | end | |||
|
9 | ||||
|
10 | # TODO: The gem or official version of ObjectDaddy doesn't set | |||
|
11 | # protected attributes so they need to be wrapped. | |||
4 | def User.generate_with_protected!(attributes={}) |
|
12 | def User.generate_with_protected!(attributes={}) | |
|
13 | user = User.spawn_with_protected(attributes) | |||
|
14 | user.save! | |||
|
15 | user | |||
|
16 | end | |||
|
17 | ||||
|
18 | # TODO: The gem or official version of ObjectDaddy doesn't set | |||
|
19 | # protected attributes so they need to be wrapped. | |||
|
20 | def User.spawn_with_protected(attributes={}) | |||
5 | user = User.spawn(attributes) do |user| |
|
21 | user = User.spawn(attributes) do |user| | |
6 | user.login = User.next_login |
|
22 | user.login = User.next_login | |
7 | attributes.each do |attr,v| |
|
23 | attributes.each do |attr,v| | |
8 | user.send("#{attr}=", v) |
|
24 | user.send("#{attr}=", v) | |
9 | end |
|
25 | end | |
10 | end |
|
26 | end | |
11 | user.save! |
|
|||
12 | user |
|
27 | user | |
13 | end |
|
28 | end | |
14 |
|
29 |
General Comments 0
You need to be logged in to leave comments.
Login now