hyperactiveform 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,115 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: TestUnit::Generators
8
+
9
+ &mdash; Documentation by YARD 0.9.37
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "TestUnit::Generators";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (G)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../TestUnit.html" title="TestUnit (module)">TestUnit</a></span></span>
41
+ &raquo;
42
+ <span class="title">Generators</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: TestUnit::Generators
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/generators/test_unit/form_generator.rb</dd>
82
+ </dl>
83
+
84
+ </div>
85
+
86
+ <h2>Defined Under Namespace</h2>
87
+ <p class="children">
88
+
89
+
90
+
91
+
92
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Generators/FormGenerator.html" title="TestUnit::Generators::FormGenerator (class)">FormGenerator</a></span>
93
+
94
+
95
+ </p>
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+ </div>
106
+
107
+ <div id="footer">
108
+ Generated on Mon Jan 13 17:26:04 2025 by
109
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
110
+ 0.9.37 (ruby-3.3.1).
111
+ </div>
112
+
113
+ </div>
114
+ </body>
115
+ </html>
@@ -0,0 +1,115 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: TestUnit
8
+
9
+ &mdash; Documentation by YARD 0.9.37
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "TestUnit";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index (T)</a> &raquo;
40
+
41
+
42
+ <span class="title">TestUnit</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: TestUnit
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/generators/test_unit/form_generator.rb</dd>
82
+ </dl>
83
+
84
+ </div>
85
+
86
+ <h2>Defined Under Namespace</h2>
87
+ <p class="children">
88
+
89
+
90
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="TestUnit/Generators.html" title="TestUnit::Generators (module)">Generators</a></span>
91
+
92
+
93
+
94
+
95
+ </p>
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+ </div>
106
+
107
+ <div id="footer">
108
+ Generated on Mon Jan 13 17:26:04 2025 by
109
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
110
+ 0.9.37 (ruby-3.3.1).
111
+ </div>
112
+
113
+ </div>
114
+ </body>
115
+ </html>
data/docs/_index.html CHANGED
@@ -117,6 +117,25 @@
117
117
 
118
118
  </li>
119
119
 
120
+ <li>
121
+ <span class='object_link'><a href="FormGenerator.html" title="FormGenerator (class)">FormGenerator</a></span>
122
+
123
+ </li>
124
+
125
+ <li>
126
+ <span class='object_link'><a href="Rspec/Generators/FormGenerator.html" title="Rspec::Generators::FormGenerator (class)">FormGenerator</a></span>
127
+
128
+ <small>(Rspec::Generators)</small>
129
+
130
+ </li>
131
+
132
+ <li>
133
+ <span class='object_link'><a href="TestUnit/Generators/FormGenerator.html" title="TestUnit::Generators::FormGenerator (class)">FormGenerator</a></span>
134
+
135
+ <small>(TestUnit::Generators)</small>
136
+
137
+ </li>
138
+
120
139
  </ul>
121
140
  </ul>
122
141
 
@@ -132,6 +151,20 @@
132
151
 
133
152
  </li>
134
153
 
154
+ <li>
155
+ <span class='object_link'><a href="Rspec/Generators.html" title="Rspec::Generators (module)">Generators</a></span>
156
+
157
+ <small>(Rspec)</small>
158
+
159
+ </li>
160
+
161
+ <li>
162
+ <span class='object_link'><a href="TestUnit/Generators.html" title="TestUnit::Generators (module)">Generators</a></span>
163
+
164
+ <small>(TestUnit)</small>
165
+
166
+ </li>
167
+
135
168
  </ul>
136
169
  </ul>
137
170
 
@@ -163,6 +196,35 @@
163
196
  </ul>
164
197
  </ul>
165
198
 
199
+
200
+ <ul id="alpha_R" class="alpha">
201
+ <li class="letter">R</li>
202
+ <ul>
203
+
204
+ <li>
205
+ <span class='object_link'><a href="Rspec.html" title="Rspec (module)">Rspec</a></span>
206
+
207
+ </li>
208
+
209
+ </ul>
210
+ </ul>
211
+
212
+
213
+ </td><td valign='top' width="33%">
214
+
215
+
216
+ <ul id="alpha_T" class="alpha">
217
+ <li class="letter">T</li>
218
+ <ul>
219
+
220
+ <li>
221
+ <span class='object_link'><a href="TestUnit.html" title="TestUnit (module)">TestUnit</a></span>
222
+
223
+ </li>
224
+
225
+ </ul>
226
+ </ul>
227
+
166
228
  </td>
167
229
  </tr>
168
230
  </table>
@@ -172,7 +234,7 @@
172
234
  </div>
173
235
 
174
236
  <div id="footer">
175
- Generated on Sat Dec 14 13:22:03 2024 by
237
+ Generated on Mon Jan 13 17:26:03 2025 by
176
238
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
177
239
  0.9.37 (ruby-3.3.1).
178
240
  </div>
data/docs/class_list.html CHANGED
@@ -46,7 +46,7 @@
46
46
 
47
47
  <ul id="full_list" class="class">
48
48
  <li id="object_" class="odd"><div class="item" style="padding-left:30px"><span class='object_link'><a href="top-level-namespace.html" title="Top Level Namespace (root)">Top Level Namespace</a></span></div></li>
49
- <li id='object_HyperActiveForm' class='even'><div class='item' style='padding-left:30px'><a tabindex='0' class='toggle' role='button' aria-label='HyperActiveForm child nodes' aria-expanded='false' aria-controls='object_HyperActiveForm'></a> <span class='object_link'><a href="HyperActiveForm.html" title="HyperActiveForm (module)">HyperActiveForm</a></span><small class='search_info'>Top Level Namespace</small></div><div aria-labelledby='object_HyperActiveForm'><ul><li id='object_HyperActiveForm::Base' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="HyperActiveForm/Base.html" title="HyperActiveForm::Base (class)">Base</a></span> &lt; Object<small class='search_info'>HyperActiveForm</small></div></li><li id='object_HyperActiveForm::CancelFormSubmit' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="HyperActiveForm/CancelFormSubmit.html" title="HyperActiveForm::CancelFormSubmit (class)">CancelFormSubmit</a></span> &lt; StandardError<small class='search_info'>HyperActiveForm</small></div></li><li id='object_HyperActiveForm::FormDidNotSubmitError' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="HyperActiveForm/FormDidNotSubmitError.html" title="HyperActiveForm::FormDidNotSubmitError (class)">FormDidNotSubmitError</a></span> &lt; StandardError<small class='search_info'>HyperActiveForm</small></div></li><li id='object_HyperActiveForm::Generators' class='collapsed even'><div class='item' style='padding-left:45px'><a tabindex='0' class='toggle' role='button' aria-label='Generators child nodes' aria-expanded='false' aria-controls='object_HyperActiveForm::Generators'></a> <span class='object_link'><a href="HyperActiveForm/Generators.html" title="HyperActiveForm::Generators (module)">Generators</a></span><small class='search_info'>HyperActiveForm</small></div><div aria-labelledby='object_HyperActiveForm::Generators'><ul><li id='object_HyperActiveForm::Generators::InstallGenerator' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="HyperActiveForm/Generators/InstallGenerator.html" title="HyperActiveForm::Generators::InstallGenerator (class)">InstallGenerator</a></span> &lt; Base<small class='search_info'>HyperActiveForm::Generators</small></div></li></ul></div></li></ul></div></li>
49
+ <li id='object_FormGenerator' class='even'><div class='item' style='padding-left:30px'><span class='object_link'><a href="FormGenerator.html" title="FormGenerator (class)">FormGenerator</a></span> &lt; NamedBase<small class='search_info'>Top Level Namespace</small></div></li><li id='object_HyperActiveForm' class='odd'><div class='item' style='padding-left:30px'><a tabindex='0' class='toggle' role='button' aria-label='HyperActiveForm child nodes' aria-expanded='false' aria-controls='object_HyperActiveForm'></a> <span class='object_link'><a href="HyperActiveForm.html" title="HyperActiveForm (module)">HyperActiveForm</a></span><small class='search_info'>Top Level Namespace</small></div><div aria-labelledby='object_HyperActiveForm'><ul><li id='object_HyperActiveForm::Base' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="HyperActiveForm/Base.html" title="HyperActiveForm::Base (class)">Base</a></span> &lt; Object<small class='search_info'>HyperActiveForm</small></div></li><li id='object_HyperActiveForm::CancelFormSubmit' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="HyperActiveForm/CancelFormSubmit.html" title="HyperActiveForm::CancelFormSubmit (class)">CancelFormSubmit</a></span> &lt; StandardError<small class='search_info'>HyperActiveForm</small></div></li><li id='object_HyperActiveForm::FormDidNotSubmitError' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="HyperActiveForm/FormDidNotSubmitError.html" title="HyperActiveForm::FormDidNotSubmitError (class)">FormDidNotSubmitError</a></span> &lt; StandardError<small class='search_info'>HyperActiveForm</small></div></li><li id='object_HyperActiveForm::Generators' class='collapsed odd'><div class='item' style='padding-left:45px'><a tabindex='0' class='toggle' role='button' aria-label='Generators child nodes' aria-expanded='false' aria-controls='object_HyperActiveForm::Generators'></a> <span class='object_link'><a href="HyperActiveForm/Generators.html" title="HyperActiveForm::Generators (module)">Generators</a></span><small class='search_info'>HyperActiveForm</small></div><div aria-labelledby='object_HyperActiveForm::Generators'><ul><li id='object_HyperActiveForm::Generators::InstallGenerator' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="HyperActiveForm/Generators/InstallGenerator.html" title="HyperActiveForm::Generators::InstallGenerator (class)">InstallGenerator</a></span> &lt; Base<small class='search_info'>HyperActiveForm::Generators</small></div></li></ul></div></li></ul></div></li><li id='object_Rspec' class='even'><div class='item' style='padding-left:30px'><a tabindex='0' class='toggle' role='button' aria-label='Rspec child nodes' aria-expanded='false' aria-controls='object_Rspec'></a> <span class='object_link'><a href="Rspec.html" title="Rspec (module)">Rspec</a></span><small class='search_info'>Top Level Namespace</small></div><div aria-labelledby='object_Rspec'><ul><li id='object_Rspec::Generators' class='collapsed odd'><div class='item' style='padding-left:45px'><a tabindex='0' class='toggle' role='button' aria-label='Generators child nodes' aria-expanded='false' aria-controls='object_Rspec::Generators'></a> <span class='object_link'><a href="Rspec/Generators.html" title="Rspec::Generators (module)">Generators</a></span><small class='search_info'>Rspec</small></div><div aria-labelledby='object_Rspec::Generators'><ul><li id='object_Rspec::Generators::FormGenerator' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Rspec/Generators/FormGenerator.html" title="Rspec::Generators::FormGenerator (class)">FormGenerator</a></span> &lt; NamedBase<small class='search_info'>Rspec::Generators</small></div></li></ul></div></li></ul></div></li><li id='object_TestUnit' class='even'><div class='item' style='padding-left:30px'><a tabindex='0' class='toggle' role='button' aria-label='TestUnit child nodes' aria-expanded='false' aria-controls='object_TestUnit'></a> <span class='object_link'><a href="TestUnit.html" title="TestUnit (module)">TestUnit</a></span><small class='search_info'>Top Level Namespace</small></div><div aria-labelledby='object_TestUnit'><ul><li id='object_TestUnit::Generators' class='collapsed odd'><div class='item' style='padding-left:45px'><a tabindex='0' class='toggle' role='button' aria-label='Generators child nodes' aria-expanded='false' aria-controls='object_TestUnit::Generators'></a> <span class='object_link'><a href="TestUnit/Generators.html" title="TestUnit::Generators (module)">Generators</a></span><small class='search_info'>TestUnit</small></div><div aria-labelledby='object_TestUnit::Generators'><ul><li id='object_TestUnit::Generators::FormGenerator' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="TestUnit/Generators/FormGenerator.html" title="TestUnit::Generators::FormGenerator (class)">FormGenerator</a></span> &lt; NamedBase<small class='search_info'>TestUnit::Generators</small></div></li></ul></div></li></ul></div></li>
50
50
 
51
51
  </ul>
52
52
  </div>
@@ -87,6 +87,15 @@
87
87
 
88
88
  <p>this will create an <code>ApplicationForm</code> class in your app/forms directory. You can use it as a base class for your form objects.</p>
89
89
 
90
+ <h2 id="label-Generators">Generators</h2>
91
+
92
+ <p>You can <a href="https://guides.rubyonrails.org/configuring.html#configuring-generators">generate</a> a form and its tests with the following command:</p>
93
+
94
+ <pre class="code ruby"><code class="ruby">$ rails generate form FooBar
95
+ </code></pre>
96
+
97
+ <p>This will create the <code>FooBarForm</code></p>
98
+
90
99
  <h2 id="label-Usage">Usage</h2>
91
100
 
92
101
  <p>Here is an example of an <code>HyperActiveForm</code> form object:</p>
@@ -257,11 +266,40 @@
257
266
 
258
267
  <p>And in the controller:</p>
259
268
 
260
- <p>“‘ruby class UsersController &lt; ApplicationController def index @form = UserSearchForm.new @<a href=":user">form.submit!(params</a>) @users = @form.results end end</p>
269
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>UsersController</span> <span class='op'>&lt;</span> <span class='const'>ApplicationController</span>
270
+ <span class='kw'>def</span> <span class='id identifier rubyid_index'>index</span>
271
+ <span class='ivar'>@form</span> <span class='op'>=</span> <span class='const'>UserSearchForm</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
272
+ <span class='ivar'>@form</span><span class='period'>.</span><span class='id identifier rubyid_submit!'>submit!</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:user</span><span class='rbracket'>]</span><span class='rparen'>)</span>
273
+ <span class='ivar'>@users</span> <span class='op'>=</span> <span class='ivar'>@form</span><span class='period'>.</span><span class='id identifier rubyid_results'>results</span>
274
+ <span class='kw'>end</span>
275
+ <span class='kw'>end</span>
276
+ </code></pre>
277
+
278
+ <h2 id="label-Callbacks">Callbacks</h2>
279
+
280
+ <p>HyperActiveForm provides callbacks for <code>assign_form_attributes</code> and <code>submit</code>.</p>
281
+
282
+ <p>You can use these callbacks to run code before or after assigning the form attributes or before or after submitting the form.</p>
283
+
284
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>ProfileForm</span> <span class='op'>&lt;</span> <span class='const'>ApplicationForm</span>
285
+ <span class='comment'># ...
286
+ </span>
287
+ <span class='id identifier rubyid_before_submit'>before_submit</span> <span class='symbol'>:do_something_before_submit</span>
288
+ <span class='id identifier rubyid_before_assign_form_attributes'>before_assign_form_attributes</span> <span class='symbol'>:do_something_before_assign_form_attributes</span>
289
+
290
+ <span class='kw'>def</span> <span class='id identifier rubyid_do_something_before_submit'>do_something_before_submit</span>
291
+ <span class='comment'># Do something before submitting the form
292
+ </span> <span class='kw'>end</span>
293
+
294
+ <span class='kw'>def</span> <span class='id identifier rubyid_do_something_before_assign_form_attributes'>do_something_before_assign_form_attributes</span>
295
+ <span class='comment'># Do something before assigning the form attributes
296
+ </span> <span class='kw'>end</span>
297
+ <span class='kw'>end</span>
298
+ </code></pre>
261
299
  </div></div>
262
300
 
263
301
  <div id="footer">
264
- Generated on Sat Dec 14 13:22:03 2024 by
302
+ Generated on Mon Jan 13 17:26:04 2025 by
265
303
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
266
304
  0.9.37 (ruby-3.3.1).
267
305
  </div>
data/docs/index.html CHANGED
@@ -87,6 +87,15 @@
87
87
 
88
88
  <p>this will create an <code>ApplicationForm</code> class in your app/forms directory. You can use it as a base class for your form objects.</p>
89
89
 
90
+ <h2 id="label-Generators">Generators</h2>
91
+
92
+ <p>You can <a href="https://guides.rubyonrails.org/configuring.html#configuring-generators">generate</a> a form and its tests with the following command:</p>
93
+
94
+ <pre class="code ruby"><code class="ruby">$ rails generate form FooBar
95
+ </code></pre>
96
+
97
+ <p>This will create the <code>FooBarForm</code></p>
98
+
90
99
  <h2 id="label-Usage">Usage</h2>
91
100
 
92
101
  <p>Here is an example of an <code>HyperActiveForm</code> form object:</p>
@@ -257,11 +266,40 @@
257
266
 
258
267
  <p>And in the controller:</p>
259
268
 
260
- <p>“‘ruby class UsersController &lt; ApplicationController def index @form = UserSearchForm.new @<a href=":user">form.submit!(params</a>) @users = @form.results end end</p>
269
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>UsersController</span> <span class='op'>&lt;</span> <span class='const'>ApplicationController</span>
270
+ <span class='kw'>def</span> <span class='id identifier rubyid_index'>index</span>
271
+ <span class='ivar'>@form</span> <span class='op'>=</span> <span class='const'>UserSearchForm</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
272
+ <span class='ivar'>@form</span><span class='period'>.</span><span class='id identifier rubyid_submit!'>submit!</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:user</span><span class='rbracket'>]</span><span class='rparen'>)</span>
273
+ <span class='ivar'>@users</span> <span class='op'>=</span> <span class='ivar'>@form</span><span class='period'>.</span><span class='id identifier rubyid_results'>results</span>
274
+ <span class='kw'>end</span>
275
+ <span class='kw'>end</span>
276
+ </code></pre>
277
+
278
+ <h2 id="label-Callbacks">Callbacks</h2>
279
+
280
+ <p>HyperActiveForm provides callbacks for <code>assign_form_attributes</code> and <code>submit</code>.</p>
281
+
282
+ <p>You can use these callbacks to run code before or after assigning the form attributes or before or after submitting the form.</p>
283
+
284
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>ProfileForm</span> <span class='op'>&lt;</span> <span class='const'>ApplicationForm</span>
285
+ <span class='comment'># ...
286
+ </span>
287
+ <span class='id identifier rubyid_before_submit'>before_submit</span> <span class='symbol'>:do_something_before_submit</span>
288
+ <span class='id identifier rubyid_before_assign_form_attributes'>before_assign_form_attributes</span> <span class='symbol'>:do_something_before_assign_form_attributes</span>
289
+
290
+ <span class='kw'>def</span> <span class='id identifier rubyid_do_something_before_submit'>do_something_before_submit</span>
291
+ <span class='comment'># Do something before submitting the form
292
+ </span> <span class='kw'>end</span>
293
+
294
+ <span class='kw'>def</span> <span class='id identifier rubyid_do_something_before_assign_form_attributes'>do_something_before_assign_form_attributes</span>
295
+ <span class='comment'># Do something before assigning the form attributes
296
+ </span> <span class='kw'>end</span>
297
+ <span class='kw'>end</span>
298
+ </code></pre>
261
299
  </div></div>
262
300
 
263
301
  <div id="footer">
264
- Generated on Sat Dec 14 13:22:03 2024 by
302
+ Generated on Mon Jan 13 17:26:04 2025 by
265
303
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
266
304
  0.9.37 (ruby-3.3.1).
267
305
  </div>
@@ -64,6 +64,14 @@
64
64
 
65
65
 
66
66
  <li class="odd ">
67
+ <div class="item">
68
+ <span class='object_link'><a href="HyperActiveForm/Base.html#assigned_attribute_names-instance_method" title="HyperActiveForm::Base#assigned_attribute_names (method)">#assigned_attribute_names</a></span>
69
+ <small>HyperActiveForm::Base</small>
70
+ </div>
71
+ </li>
72
+
73
+
74
+ <li class="even ">
67
75
  <div class="item">
68
76
  <span class='object_link'><a href="HyperActiveForm/Generators/InstallGenerator.html#create_application_form-instance_method" title="HyperActiveForm::Generators::InstallGenerator#create_application_form (method)">#create_application_form</a></span>
69
77
  <small>HyperActiveForm::Generators::InstallGenerator</small>
@@ -71,6 +79,30 @@
71
79
  </li>
72
80
 
73
81
 
82
+ <li class="odd ">
83
+ <div class="item">
84
+ <span class='object_link'><a href="FormGenerator.html#create_application_form-instance_method" title="FormGenerator#create_application_form (method)">#create_application_form</a></span>
85
+ <small>FormGenerator</small>
86
+ </div>
87
+ </li>
88
+
89
+
90
+ <li class="even ">
91
+ <div class="item">
92
+ <span class='object_link'><a href="Rspec/Generators/FormGenerator.html#create_form_spec-instance_method" title="Rspec::Generators::FormGenerator#create_form_spec (method)">#create_form_spec</a></span>
93
+ <small>Rspec::Generators::FormGenerator</small>
94
+ </div>
95
+ </li>
96
+
97
+
98
+ <li class="odd ">
99
+ <div class="item">
100
+ <span class='object_link'><a href="TestUnit/Generators/FormGenerator.html#create_form_test-instance_method" title="TestUnit::Generators::FormGenerator#create_form_test (method)">#create_form_test</a></span>
101
+ <small>TestUnit::Generators::FormGenerator</small>
102
+ </div>
103
+ </li>
104
+
105
+
74
106
  <li class="even ">
75
107
  <div class="item">
76
108
  <span class='object_link'><a href="HyperActiveForm/Base.html#initialize-instance_method" title="HyperActiveForm::Base#initialize (method)">#initialize</a></span>
@@ -82,10 +82,12 @@
82
82
  <p class="children">
83
83
 
84
84
 
85
- <strong class="modules">Modules:</strong> <span class='object_link'><a href="HyperActiveForm.html" title="HyperActiveForm (module)">HyperActiveForm</a></span>
85
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="HyperActiveForm.html" title="HyperActiveForm (module)">HyperActiveForm</a></span>, <span class='object_link'><a href="Rspec.html" title="Rspec (module)">Rspec</a></span>, <span class='object_link'><a href="TestUnit.html" title="TestUnit (module)">TestUnit</a></span>
86
86
 
87
87
 
88
88
 
89
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="FormGenerator.html" title="FormGenerator (class)">FormGenerator</a></span>
90
+
89
91
 
90
92
  </p>
91
93
 
@@ -100,7 +102,7 @@
100
102
  </div>
101
103
 
102
104
  <div id="footer">
103
- Generated on Sat Dec 14 13:22:03 2024 by
105
+ Generated on Mon Jan 13 17:26:04 2025 by
104
106
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
107
  0.9.37 (ruby-3.3.1).
106
108
  </div>
@@ -19,6 +19,10 @@ module HyperActiveForm
19
19
 
20
20
  define_model_callbacks :assign_form_attributes, :submit
21
21
 
22
+ # The list of attribute names that have been passed to the form
23
+ # during the last call to `assign_form_attributes` or `submit`
24
+ attr_reader :assigned_attribute_names
25
+
22
26
  # Defines to which object the form should delegate the active model methods
23
27
  # This is useful so `form_for`/`form_with` can automatically deduce the url and method to use
24
28
  #
@@ -51,8 +55,13 @@ module HyperActiveForm
51
55
  params = ActionController::Parameters.new(params) unless params.is_a?(ActionController::Parameters)
52
56
  attribute_names.each do |attribute|
53
57
  default_value = self.class._default_attributes[attribute]&.value_before_type_cast
54
- public_send(:"#{attribute}=", params&.dig(attribute) || default_value)
58
+ if params&.key?(attribute)
59
+ public_send(:"#{attribute}=", params&.dig(attribute))
60
+ else
61
+ public_send(:"#{attribute}=", default_value)
62
+ end
55
63
  end
64
+ @assigned_attribute_names = params.slice(*attribute_names).keys
56
65
  end
57
66
  end
58
67
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HyperActiveForm
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyperactiveform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Siami
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-22 00:00:00.000000000 Z
11
+ date: 2025-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -59,17 +59,25 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".DS_Store"
62
63
  - ".rspec"
63
64
  - CHANGELOG.md
64
65
  - LICENSE.txt
65
66
  - README.md
66
67
  - Rakefile
68
+ - docs/FormGenerator.html
67
69
  - docs/HyperActiveForm.html
68
70
  - docs/HyperActiveForm/Base.html
69
71
  - docs/HyperActiveForm/CancelFormSubmit.html
70
72
  - docs/HyperActiveForm/FormDidNotSubmitError.html
71
73
  - docs/HyperActiveForm/Generators.html
72
74
  - docs/HyperActiveForm/Generators/InstallGenerator.html
75
+ - docs/Rspec.html
76
+ - docs/Rspec/Generators.html
77
+ - docs/Rspec/Generators/FormGenerator.html
78
+ - docs/TestUnit.html
79
+ - docs/TestUnit/Generators.html
80
+ - docs/TestUnit/Generators/FormGenerator.html
73
81
  - docs/_index.html
74
82
  - docs/class_list.html
75
83
  - docs/css/common.css
@@ -122,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
130
  - !ruby/object:Gem::Version
123
131
  version: '0'
124
132
  requirements: []
125
- rubygems_version: 3.5.10
133
+ rubygems_version: 3.5.9
126
134
  signing_key:
127
135
  specification_version: 4
128
136
  summary: Simple form objects for Rails