mack-data_factory 0.6.1.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. data/README +22 -23
  2. data/doc/classes/Kernel.html +15 -15
  3. data/doc/classes/Mack.html +0 -6
  4. data/doc/classes/Mack/Data/Bridge.html +36 -36
  5. data/doc/classes/Mack/Data/Factory/ClassMethods.html +44 -16
  6. data/doc/classes/Mack/Data/Factory/FieldContentGenerator.html +324 -305
  7. data/doc/classes/Mack/Data/Field.html +81 -77
  8. data/doc/classes/Mack/Data/FieldMgr.html +23 -23
  9. data/doc/classes/Mack/Data/OrmBridge/ActiveRecord.html +36 -36
  10. data/doc/classes/Mack/Data/OrmBridge/DataMapper.html +36 -36
  11. data/doc/classes/Mack/Data/OrmBridge/Default.html +45 -45
  12. data/doc/created.rid +1 -1
  13. data/doc/files/README.html +1 -1
  14. data/doc/files/lib/mack-data_factory/content_generator_rb.html +8 -1
  15. data/doc/files/lib/mack-data_factory/core_extensions/kernel_rb.html +1 -1
  16. data/doc/files/lib/mack-data_factory/data_factory_rb.html +1 -1
  17. data/doc/files/lib/mack-data_factory/field_manager_rb.html +1 -1
  18. data/doc/files/lib/mack-data_factory/field_rb.html +1 -1
  19. data/doc/files/lib/mack-data_factory/orm_api_bridge/bridge_rb.html +1 -1
  20. data/doc/files/lib/mack-data_factory/orm_api_bridge/orm/default_rb.html +1 -1
  21. data/doc/fr_class_index.html +0 -5
  22. data/doc/fr_method_index.html +50 -49
  23. data/lib/mack-data_factory/content_generator.rb +22 -7
  24. data/lib/mack-data_factory/core_extensions/kernel.rb +1 -1
  25. data/lib/mack-data_factory/data_factory.rb +11 -4
  26. data/lib/mack-data_factory/field.rb +18 -14
  27. data/lib/mack-data_factory/field_manager.rb +3 -3
  28. data/lib/mack-data_factory/orm_api_bridge/bridge.rb +1 -1
  29. data/lib/mack-data_factory/orm_api_bridge/orm/default.rb +18 -18
  30. metadata +2 -2
@@ -86,8 +86,8 @@
86
86
  <h3 class="section-bar">Methods</h3>
87
87
 
88
88
  <div class="name-list">
89
- <a href="#M000044">get_value</a>&nbsp;&nbsp;
90
- <a href="#M000043">new</a>&nbsp;&nbsp;
89
+ <a href="#M000045">get_value</a>&nbsp;&nbsp;
90
+ <a href="#M000044">new</a>&nbsp;&nbsp;
91
91
  </div>
92
92
  </div>
93
93
 
@@ -137,19 +137,19 @@
137
137
  <div id="methods">
138
138
  <h3 class="section-bar">Public Class methods</h3>
139
139
 
140
- <div id="method-M000043" class="method-detail">
141
- <a name="M000043"></a>
140
+ <div id="method-M000044" class="method-detail">
141
+ <a name="M000044"></a>
142
142
 
143
143
  <div class="method-heading">
144
- <a href="#M000043" class="method-signature">
144
+ <a href="#M000044" class="method-signature">
145
145
  <span class="method-name">new</span><span class="method-args">(hash = {})</span>
146
146
  </a>
147
147
  </div>
148
148
 
149
149
  <div class="method-description">
150
150
  <p><a class="source-toggle" href="#"
151
- onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
152
- <div class="method-source-code" id="M000043-source">
151
+ onclick="toggleCode('M000044-source');return false;">[Source]</a></p>
152
+ <div class="method-source-code" id="M000044-source">
153
153
  <pre>
154
154
  <span class="ruby-comment cmt"># File lib/mack-data_factory/field.rb, line 13</span>
155
155
  13: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">hash</span> = {})
@@ -161,20 +161,23 @@
161
161
  19: <span class="ruby-keyword kw">end</span>
162
162
  20:
163
163
  21: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_rules</span> = {
164
- 22: <span class="ruby-identifier">:immutable</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
165
- 23: <span class="ruby-identifier">:length</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">256</span>,
166
- 24: <span class="ruby-identifier">:add_space</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
167
- 25: <span class="ruby-identifier">:content</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:alpha_numeric</span>,
168
- 26: <span class="ruby-identifier">:null_frequency</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>
169
- 27: }.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:field_rules</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:field_rules</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
170
- 28:
171
- 29: <span class="ruby-comment cmt"># transform the content type based on the given default value</span>
172
- 30: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">field_value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Fixnum</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">field_value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Integer</span>)
173
- 31: <span class="ruby-identifier">field_rules</span>[<span class="ruby-identifier">:content</span>] = <span class="ruby-identifier">:numeric</span>
174
- 32: <span class="ruby-keyword kw">end</span>
175
- 33:
176
- 34: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_value_producer</span> = <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Data</span><span class="ruby-operator">::</span><span class="ruby-constant">Factory</span><span class="ruby-operator">::</span><span class="ruby-constant">FieldContentGenerator</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{field_rules[:content]}_generator&quot;</span>)
177
- 35: <span class="ruby-keyword kw">end</span>
164
+ 22: <span class="ruby-identifier">:default</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;&quot;</span>,
165
+ 23: <span class="ruby-identifier">:immutable</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
166
+ 24: <span class="ruby-identifier">:length</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">256</span>,
167
+ 25: <span class="ruby-identifier">:add_space</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
168
+ 26: <span class="ruby-identifier">:content</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:alpha_numeric</span>,
169
+ 27: <span class="ruby-identifier">:null_frequency</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>
170
+ 28: }.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:field_rules</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:field_rules</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
171
+ 29:
172
+ 30: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_value</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_rules</span>[<span class="ruby-identifier">:default</span>]
173
+ 31:
174
+ 32: <span class="ruby-comment cmt"># transform the content type based on the given default value</span>
175
+ 33: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Fixnum</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Integer</span>)
176
+ 34: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_rules</span>[<span class="ruby-identifier">:content</span>] = <span class="ruby-identifier">:numeric</span>
177
+ 35: <span class="ruby-keyword kw">end</span>
178
+ 36:
179
+ 37: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_value_producer</span> = <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Data</span><span class="ruby-operator">::</span><span class="ruby-constant">Factory</span><span class="ruby-operator">::</span><span class="ruby-constant">FieldContentGenerator</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{self.field_rules[:content]}_generator&quot;</span>)
180
+ 38: <span class="ruby-keyword kw">end</span>
178
181
  </pre>
179
182
  </div>
180
183
  </div>
@@ -182,71 +185,72 @@
182
185
 
183
186
  <h3 class="section-bar">Public Instance methods</h3>
184
187
 
185
- <div id="method-M000044" class="method-detail">
186
- <a name="M000044"></a>
188
+ <div id="method-M000045" class="method-detail">
189
+ <a name="M000045"></a>
187
190
 
188
191
  <div class="method-heading">
189
- <a href="#M000044" class="method-signature">
192
+ <a href="#M000045" class="method-signature">
190
193
  <span class="method-name">get_value</span><span class="method-args">(index = 0)</span>
191
194
  </a>
192
195
  </div>
193
196
 
194
197
  <div class="method-description">
195
198
  <p><a class="source-toggle" href="#"
196
- onclick="toggleCode('M000044-source');return false;">[Source]</a></p>
197
- <div class="method-source-code" id="M000044-source">
199
+ onclick="toggleCode('M000045-source');return false;">[Source]</a></p>
200
+ <div class="method-source-code" id="M000045-source">
198
201
  <pre>
199
- <span class="ruby-comment cmt"># File lib/mack-data_factory/field.rb, line 37</span>
200
- 37: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_value</span>(<span class="ruby-identifier">index</span> = <span class="ruby-value">0</span>)
201
- 38: <span class="ruby-comment cmt"># return the field_value immediately if the rule states that it's immutable</span>
202
- 39: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">field_value</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">field_rules</span>[<span class="ruby-identifier">:immutable</span>]
203
- 40:
204
- 41: <span class="ruby-comment cmt"># </span>
205
- 42: <span class="ruby-comment cmt"># if the value is a hash, then it's a relationship mapping</span>
206
- 43: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">field_value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
207
- 44: <span class="ruby-identifier">owner</span> = <span class="ruby-identifier">field_value</span>.<span class="ruby-identifier">keys</span>[<span class="ruby-value">0</span>]
208
- 45: <span class="ruby-identifier">key</span> = <span class="ruby-identifier">field_value</span>[<span class="ruby-identifier">owner</span>]
209
- 46: <span class="ruby-keyword kw">begin</span>
210
- 47: <span class="ruby-identifier">owner_model</span> = <span class="ruby-identifier">owner</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">camelcase</span>.<span class="ruby-identifier">constantize</span>
211
- 48: <span class="ruby-identifier">bridge</span> = <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Data</span><span class="ruby-operator">::</span><span class="ruby-constant">Bridge</span>.<span class="ruby-identifier">new</span>
212
- 49:
213
- 50: <span class="ruby-identifier">assoc_rules</span> = <span class="ruby-identifier">field_rules</span>[<span class="ruby-identifier">:assoc</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">:spread</span>
214
- 51: <span class="ruby-identifier">assoc_rules</span> = <span class="ruby-identifier">:random</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span>([<span class="ruby-identifier">:first</span>, <span class="ruby-identifier">:last</span>, <span class="ruby-identifier">:random</span>, <span class="ruby-identifier">:spread</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">assoc_rules</span>))
215
- 52: <span class="ruby-comment cmt"># cache the query once</span>
216
- 53: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Data</span><span class="ruby-operator">::</span><span class="ruby-constant">RegistryMap</span>.<span class="ruby-identifier">registered_items</span>[<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_name</span>.<span class="ruby-identifier">to_sym</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
217
- 54: <span class="ruby-identifier">all_owner_models</span> = <span class="ruby-identifier">bridge</span>.<span class="ruby-identifier">get_all</span>(<span class="ruby-identifier">owner_model</span>)
218
- 55: <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Data</span><span class="ruby-operator">::</span><span class="ruby-constant">RegistryMap</span>.<span class="ruby-identifier">add</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_name</span>.<span class="ruby-identifier">to_sym</span>, <span class="ruby-identifier">all_owner_models</span>)
219
- 56: <span class="ruby-keyword kw">end</span>
220
- 57:
221
- 58: <span class="ruby-identifier">all_owner_models</span> = <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Data</span><span class="ruby-operator">::</span><span class="ruby-constant">RegistryMap</span>.<span class="ruby-identifier">registered_items</span>[<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_name</span>.<span class="ruby-identifier">to_sym</span>][<span class="ruby-value">0</span>]
222
- 59:
223
- 60: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">assoc_rules</span>
224
- 61: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:first</span>
225
- 62: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">all_owner_models</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">send</span>(<span class="ruby-identifier">key</span>)
226
- 63: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:last</span>
227
- 64: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">all_owner_models</span>[<span class="ruby-identifier">all_owner_models</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>].<span class="ruby-identifier">send</span>(<span class="ruby-identifier">key</span>)
228
- 65: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:random</span>
229
- 66: <span class="ruby-identifier">my_index</span> = <span class="ruby-identifier">rand</span>((<span class="ruby-identifier">all_owner_models</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>))
230
- 67: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">all_owner_models</span>[<span class="ruby-identifier">my_index</span>].<span class="ruby-identifier">send</span>(<span class="ruby-identifier">key</span>)
231
- 68: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:spread</span>
232
- 69: <span class="ruby-comment cmt"># if index &gt;= all_owner_models.size </span>
233
- 70: <span class="ruby-comment cmt"># my_index = rand((all_owner_models.size - 1))</span>
234
- 71: <span class="ruby-comment cmt"># else</span>
235
- 72: <span class="ruby-comment cmt"># my_index = index</span>
236
- 73: <span class="ruby-comment cmt"># end</span>
237
- 74: <span class="ruby-identifier">my_index</span> = <span class="ruby-identifier">index</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">all_owner_models</span>.<span class="ruby-identifier">size</span>
238
- 75: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">all_owner_models</span>[<span class="ruby-identifier">my_index</span>].<span class="ruby-identifier">send</span>(<span class="ruby-identifier">key</span>)
239
- 76: <span class="ruby-keyword kw">end</span>
240
- 77:
241
- 78: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">value</span>
242
- 79: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
243
- 80: <span class="ruby-constant">Mack</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">warn</span> <span class="ruby-node">&quot;WARNING: DataFactory: field_value for #{field_name} is not set properly because data relationship defined is not correct&quot;</span>
244
- 81: <span class="ruby-keyword kw">end</span>
245
- 82: <span class="ruby-keyword kw">end</span>
246
- 83:
247
- 84: <span class="ruby-comment cmt"># must generate random string and also respect the rules</span>
248
- 85: <span class="ruby-identifier">field_value_producer</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">field_value</span>, <span class="ruby-identifier">field_rules</span>, <span class="ruby-identifier">index</span>)
249
- 86: <span class="ruby-keyword kw">end</span>
202
+ <span class="ruby-comment cmt"># File lib/mack-data_factory/field.rb, line 40</span>
203
+ 40: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_value</span>(<span class="ruby-identifier">index</span> = <span class="ruby-value">0</span>)
204
+ 41: <span class="ruby-comment cmt"># return the field_value immediately if the rule states that it's immutable</span>
205
+ 42: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_value</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_rules</span>[<span class="ruby-identifier">:immutable</span>]
206
+ 43:
207
+ 44: <span class="ruby-comment cmt"># </span>
208
+ 45: <span class="ruby-comment cmt"># if the value is a hash, then it's a relationship mapping</span>
209
+ 46: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_value</span>[<span class="ruby-identifier">:df_assoc_map</span>]
210
+ 47: <span class="ruby-identifier">map_data</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_value</span>[<span class="ruby-identifier">:df_assoc_map</span>]
211
+ 48: <span class="ruby-identifier">owner</span> = <span class="ruby-identifier">map_data</span>.<span class="ruby-identifier">keys</span>[<span class="ruby-value">0</span>]
212
+ 49: <span class="ruby-identifier">key</span> = <span class="ruby-identifier">map_data</span>[<span class="ruby-identifier">owner</span>]
213
+ 50: <span class="ruby-keyword kw">begin</span>
214
+ 51: <span class="ruby-identifier">owner_model</span> = <span class="ruby-identifier">owner</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">camelcase</span>.<span class="ruby-identifier">constantize</span>
215
+ 52: <span class="ruby-identifier">bridge</span> = <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Data</span><span class="ruby-operator">::</span><span class="ruby-constant">Bridge</span>.<span class="ruby-identifier">new</span>
216
+ 53:
217
+ 54: <span class="ruby-identifier">assoc_rules</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_rules</span>[<span class="ruby-identifier">:assoc</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">:spread</span>
218
+ 55: <span class="ruby-identifier">assoc_rules</span> = <span class="ruby-identifier">:spread</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span>([<span class="ruby-identifier">:first</span>, <span class="ruby-identifier">:last</span>, <span class="ruby-identifier">:random</span>, <span class="ruby-identifier">:spread</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">assoc_rules</span>))
219
+ 56: <span class="ruby-comment cmt"># cache the query once</span>
220
+ 57: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Data</span><span class="ruby-operator">::</span><span class="ruby-constant">RegistryMap</span>.<span class="ruby-identifier">registered_items</span>[<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_name</span>.<span class="ruby-identifier">to_sym</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
221
+ 58: <span class="ruby-identifier">all_owner_models</span> = <span class="ruby-identifier">bridge</span>.<span class="ruby-identifier">get_all</span>(<span class="ruby-identifier">owner_model</span>)
222
+ 59: <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Data</span><span class="ruby-operator">::</span><span class="ruby-constant">RegistryMap</span>.<span class="ruby-identifier">add</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_name</span>.<span class="ruby-identifier">to_sym</span>, <span class="ruby-identifier">all_owner_models</span>)
223
+ 60: <span class="ruby-keyword kw">end</span>
224
+ 61:
225
+ 62: <span class="ruby-identifier">all_owner_models</span> = <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Data</span><span class="ruby-operator">::</span><span class="ruby-constant">RegistryMap</span>.<span class="ruby-identifier">registered_items</span>[<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_name</span>.<span class="ruby-identifier">to_sym</span>][<span class="ruby-value">0</span>]
226
+ 63:
227
+ 64: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">assoc_rules</span>
228
+ 65: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:first</span>
229
+ 66: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">all_owner_models</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">send</span>(<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>)
230
+ 67: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:last</span>
231
+ 68: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">all_owner_models</span>[<span class="ruby-identifier">all_owner_models</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>].<span class="ruby-identifier">send</span>(<span class="ruby-identifier">key</span>)
232
+ 69: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:random</span>
233
+ 70: <span class="ruby-identifier">my_index</span> = <span class="ruby-identifier">rand</span>((<span class="ruby-identifier">all_owner_models</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>))
234
+ 71: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">all_owner_models</span>[<span class="ruby-identifier">my_index</span>].<span class="ruby-identifier">send</span>(<span class="ruby-identifier">key</span>)
235
+ 72: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:spread</span>
236
+ 73: <span class="ruby-comment cmt"># if index &gt;= all_owner_models.size </span>
237
+ 74: <span class="ruby-comment cmt"># my_index = rand((all_owner_models.size - 1))</span>
238
+ 75: <span class="ruby-comment cmt"># else</span>
239
+ 76: <span class="ruby-comment cmt"># my_index = index</span>
240
+ 77: <span class="ruby-comment cmt"># end</span>
241
+ 78: <span class="ruby-identifier">my_index</span> = <span class="ruby-identifier">index</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">all_owner_models</span>.<span class="ruby-identifier">size</span>
242
+ 79: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">all_owner_models</span>[<span class="ruby-identifier">my_index</span>].<span class="ruby-identifier">send</span>(<span class="ruby-identifier">key</span>)
243
+ 80: <span class="ruby-keyword kw">end</span>
244
+ 81:
245
+ 82: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">value</span>
246
+ 83: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>
247
+ 84: <span class="ruby-constant">Mack</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">warn</span> <span class="ruby-node">&quot;WARNING: DataFactory: id_map for #{field_name} is not set properly because data relationship defined is not correct&quot;</span>
248
+ 85: <span class="ruby-keyword kw">end</span>
249
+ 86: <span class="ruby-keyword kw">end</span>
250
+ 87:
251
+ 88: <span class="ruby-comment cmt"># must generate random string and also respect the rules</span>
252
+ 89: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_value_producer</span>.<span class="ruby-identifier">call</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_value</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">field_rules</span>, <span class="ruby-identifier">index</span>)
253
+ 90: <span class="ruby-keyword kw">end</span>
250
254
  </pre>
251
255
  </div>
252
256
  </div>
@@ -86,9 +86,9 @@
86
86
  <h3 class="section-bar">Methods</h3>
87
87
 
88
88
  <div class="name-list">
89
- <a href="#M000041">add</a>&nbsp;&nbsp;
90
- <a href="#M000042">fields</a>&nbsp;&nbsp;
91
- <a href="#M000040">new</a>&nbsp;&nbsp;
89
+ <a href="#M000042">add</a>&nbsp;&nbsp;
90
+ <a href="#M000043">fields</a>&nbsp;&nbsp;
91
+ <a href="#M000041">new</a>&nbsp;&nbsp;
92
92
  </div>
93
93
  </div>
94
94
 
@@ -123,19 +123,19 @@
123
123
  <div id="methods">
124
124
  <h3 class="section-bar">Public Class methods</h3>
125
125
 
126
- <div id="method-M000040" class="method-detail">
127
- <a name="M000040"></a>
126
+ <div id="method-M000041" class="method-detail">
127
+ <a name="M000041"></a>
128
128
 
129
129
  <div class="method-heading">
130
- <a href="#M000040" class="method-signature">
130
+ <a href="#M000041" class="method-signature">
131
131
  <span class="method-name">new</span><span class="method-args">()</span>
132
132
  </a>
133
133
  </div>
134
134
 
135
135
  <div class="method-description">
136
136
  <p><a class="source-toggle" href="#"
137
- onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
138
- <div class="method-source-code" id="M000040-source">
137
+ onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
138
+ <div class="method-source-code" id="M000041-source">
139
139
  <pre>
140
140
  <span class="ruby-comment cmt"># File lib/mack-data_factory/field_manager.rb, line 6</span>
141
141
  6: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
@@ -148,25 +148,25 @@
148
148
 
149
149
  <h3 class="section-bar">Public Instance methods</h3>
150
150
 
151
- <div id="method-M000041" class="method-detail">
152
- <a name="M000041"></a>
151
+ <div id="method-M000042" class="method-detail">
152
+ <a name="M000042"></a>
153
153
 
154
154
  <div class="method-heading">
155
- <a href="#M000041" class="method-signature">
156
- <span class="method-name">add</span><span class="method-args">(scope, field_name, default_value, options = {}, &amp;block)</span>
155
+ <a href="#M000042" class="method-signature">
156
+ <span class="method-name">add</span><span class="method-args">(scope, field_name, options = {}, &amp;block)</span>
157
157
  </a>
158
158
  </div>
159
159
 
160
160
  <div class="method-description">
161
161
  <p><a class="source-toggle" href="#"
162
- onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
163
- <div class="method-source-code" id="M000041-source">
162
+ onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
163
+ <div class="method-source-code" id="M000042-source">
164
164
  <pre>
165
165
  <span class="ruby-comment cmt"># File lib/mack-data_factory/field_manager.rb, line 10</span>
166
- 10: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add</span>(<span class="ruby-identifier">scope</span>, <span class="ruby-identifier">field_name</span>, <span class="ruby-identifier">default_value</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
167
- 11: <span class="ruby-identifier">field_list</span> = <span class="ruby-identifier">fields</span>(<span class="ruby-identifier">scope</span>)
168
- 12: <span class="ruby-identifier">field_list</span>[<span class="ruby-identifier">field_name</span>] = <span class="ruby-constant">Field</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">:field_name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">field_name</span>,
169
- 13: <span class="ruby-identifier">:field_value</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">default_value</span>,
166
+ 10: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add</span>(<span class="ruby-identifier">scope</span>, <span class="ruby-identifier">field_name</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
167
+ 11: <span class="ruby-comment cmt">#default_value = options[:default] || &quot;&quot;</span>
168
+ 12: <span class="ruby-identifier">field_list</span> = <span class="ruby-identifier">fields</span>(<span class="ruby-identifier">scope</span>)
169
+ 13: <span class="ruby-identifier">field_list</span>[<span class="ruby-identifier">field_name</span>] = <span class="ruby-constant">Field</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">:field_name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">field_name</span>,
170
170
  14: <span class="ruby-identifier">:field_rules</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">options</span>)
171
171
  15: <span class="ruby-identifier">field_list</span>[<span class="ruby-identifier">field_name</span>].<span class="ruby-identifier">field_value_producer</span> = <span class="ruby-identifier">block</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
172
172
  16: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">field_list</span>
@@ -176,19 +176,19 @@
176
176
  </div>
177
177
  </div>
178
178
 
179
- <div id="method-M000042" class="method-detail">
180
- <a name="M000042"></a>
179
+ <div id="method-M000043" class="method-detail">
180
+ <a name="M000043"></a>
181
181
 
182
182
  <div class="method-heading">
183
- <a href="#M000042" class="method-signature">
183
+ <a href="#M000043" class="method-signature">
184
184
  <span class="method-name">fields</span><span class="method-args">(scope = :default)</span>
185
185
  </a>
186
186
  </div>
187
187
 
188
188
  <div class="method-description">
189
189
  <p><a class="source-toggle" href="#"
190
- onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
191
- <div class="method-source-code" id="M000042-source">
190
+ onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
191
+ <div class="method-source-code" id="M000043-source">
192
192
  <pre>
193
193
  <span class="ruby-comment cmt"># File lib/mack-data_factory/field_manager.rb, line 19</span>
194
194
  19: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fields</span>(<span class="ruby-identifier">scope</span> = <span class="ruby-identifier">:default</span>)
@@ -86,12 +86,12 @@
86
86
  <h3 class="section-bar">Methods</h3>
87
87
 
88
88
  <div class="name-list">
89
- <a href="#M000034">can_handle</a>&nbsp;&nbsp;
90
- <a href="#M000037">count</a>&nbsp;&nbsp;
91
- <a href="#M000035">get</a>&nbsp;&nbsp;
92
- <a href="#M000036">get_all</a>&nbsp;&nbsp;
93
- <a href="#M000039">get_first</a>&nbsp;&nbsp;
94
- <a href="#M000038">save</a>&nbsp;&nbsp;
89
+ <a href="#M000035">can_handle</a>&nbsp;&nbsp;
90
+ <a href="#M000038">count</a>&nbsp;&nbsp;
91
+ <a href="#M000036">get</a>&nbsp;&nbsp;
92
+ <a href="#M000037">get_all</a>&nbsp;&nbsp;
93
+ <a href="#M000040">get_first</a>&nbsp;&nbsp;
94
+ <a href="#M000039">save</a>&nbsp;&nbsp;
95
95
  </div>
96
96
  </div>
97
97
 
@@ -113,19 +113,19 @@
113
113
  <div id="methods">
114
114
  <h3 class="section-bar">Public Instance methods</h3>
115
115
 
116
- <div id="method-M000034" class="method-detail">
117
- <a name="M000034"></a>
116
+ <div id="method-M000035" class="method-detail">
117
+ <a name="M000035"></a>
118
118
 
119
119
  <div class="method-heading">
120
- <a href="#M000034" class="method-signature">
120
+ <a href="#M000035" class="method-signature">
121
121
  <span class="method-name">can_handle</span><span class="method-args">(obj)</span>
122
122
  </a>
123
123
  </div>
124
124
 
125
125
  <div class="method-description">
126
126
  <p><a class="source-toggle" href="#"
127
- onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
128
- <div class="method-source-code" id="M000034-source">
127
+ onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
128
+ <div class="method-source-code" id="M000035-source">
129
129
  <pre>
130
130
  <span class="ruby-comment cmt"># File lib/mack-data_factory/orm_api_bridge/orm/active_record.rb, line 6</span>
131
131
  6: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">can_handle</span>(<span class="ruby-identifier">obj</span>)
@@ -137,19 +137,19 @@
137
137
  </div>
138
138
  </div>
139
139
 
140
- <div id="method-M000037" class="method-detail">
141
- <a name="M000037"></a>
140
+ <div id="method-M000038" class="method-detail">
141
+ <a name="M000038"></a>
142
142
 
143
143
  <div class="method-heading">
144
- <a href="#M000037" class="method-signature">
144
+ <a href="#M000038" class="method-signature">
145
145
  <span class="method-name">count</span><span class="method-args">(obj, *args)</span>
146
146
  </a>
147
147
  </div>
148
148
 
149
149
  <div class="method-description">
150
150
  <p><a class="source-toggle" href="#"
151
- onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
152
- <div class="method-source-code" id="M000037-source">
151
+ onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
152
+ <div class="method-source-code" id="M000038-source">
153
153
  <pre>
154
154
  <span class="ruby-comment cmt"># File lib/mack-data_factory/orm_api_bridge/orm/active_record.rb, line 19</span>
155
155
  19: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">count</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
@@ -160,19 +160,19 @@
160
160
  </div>
161
161
  </div>
162
162
 
163
- <div id="method-M000035" class="method-detail">
164
- <a name="M000035"></a>
163
+ <div id="method-M000036" class="method-detail">
164
+ <a name="M000036"></a>
165
165
 
166
166
  <div class="method-heading">
167
- <a href="#M000035" class="method-signature">
167
+ <a href="#M000036" class="method-signature">
168
168
  <span class="method-name">get</span><span class="method-args">(obj, *args)</span>
169
169
  </a>
170
170
  </div>
171
171
 
172
172
  <div class="method-description">
173
173
  <p><a class="source-toggle" href="#"
174
- onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
175
- <div class="method-source-code" id="M000035-source">
174
+ onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
175
+ <div class="method-source-code" id="M000036-source">
176
176
  <pre>
177
177
  <span class="ruby-comment cmt"># File lib/mack-data_factory/orm_api_bridge/orm/active_record.rb, line 11</span>
178
178
  11: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
@@ -183,19 +183,19 @@
183
183
  </div>
184
184
  </div>
185
185
 
186
- <div id="method-M000036" class="method-detail">
187
- <a name="M000036"></a>
186
+ <div id="method-M000037" class="method-detail">
187
+ <a name="M000037"></a>
188
188
 
189
189
  <div class="method-heading">
190
- <a href="#M000036" class="method-signature">
190
+ <a href="#M000037" class="method-signature">
191
191
  <span class="method-name">get_all</span><span class="method-args">(obj, *args)</span>
192
192
  </a>
193
193
  </div>
194
194
 
195
195
  <div class="method-description">
196
196
  <p><a class="source-toggle" href="#"
197
- onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
198
- <div class="method-source-code" id="M000036-source">
197
+ onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
198
+ <div class="method-source-code" id="M000037-source">
199
199
  <pre>
200
200
  <span class="ruby-comment cmt"># File lib/mack-data_factory/orm_api_bridge/orm/active_record.rb, line 15</span>
201
201
  15: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_all</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
@@ -206,19 +206,19 @@
206
206
  </div>
207
207
  </div>
208
208
 
209
- <div id="method-M000039" class="method-detail">
210
- <a name="M000039"></a>
209
+ <div id="method-M000040" class="method-detail">
210
+ <a name="M000040"></a>
211
211
 
212
212
  <div class="method-heading">
213
- <a href="#M000039" class="method-signature">
213
+ <a href="#M000040" class="method-signature">
214
214
  <span class="method-name">get_first</span><span class="method-args">(obj, *args)</span>
215
215
  </a>
216
216
  </div>
217
217
 
218
218
  <div class="method-description">
219
219
  <p><a class="source-toggle" href="#"
220
- onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
221
- <div class="method-source-code" id="M000039-source">
220
+ onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
221
+ <div class="method-source-code" id="M000040-source">
222
222
  <pre>
223
223
  <span class="ruby-comment cmt"># File lib/mack-data_factory/orm_api_bridge/orm/active_record.rb, line 27</span>
224
224
  27: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_first</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
@@ -229,19 +229,19 @@
229
229
  </div>
230
230
  </div>
231
231
 
232
- <div id="method-M000038" class="method-detail">
233
- <a name="M000038"></a>
232
+ <div id="method-M000039" class="method-detail">
233
+ <a name="M000039"></a>
234
234
 
235
235
  <div class="method-heading">
236
- <a href="#M000038" class="method-signature">
236
+ <a href="#M000039" class="method-signature">
237
237
  <span class="method-name">save</span><span class="method-args">(obj, *args)</span>
238
238
  </a>
239
239
  </div>
240
240
 
241
241
  <div class="method-description">
242
242
  <p><a class="source-toggle" href="#"
243
- onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
244
- <div class="method-source-code" id="M000038-source">
243
+ onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
244
+ <div class="method-source-code" id="M000039-source">
245
245
  <pre>
246
246
  <span class="ruby-comment cmt"># File lib/mack-data_factory/orm_api_bridge/orm/active_record.rb, line 23</span>
247
247
  23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)