mack-data_factory 0.6.1.1 → 0.6.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/classes/Kernel.html +207 -0
- data/doc/classes/Mack.html +143 -0
- data/doc/classes/Mack/Data/Bridge.html +269 -0
- data/doc/classes/Mack/Data/Factory.html +171 -0
- data/doc/classes/Mack/Data/Factory/ClassMethods.html +262 -0
- data/doc/classes/Mack/Data/Factory/FieldContentGenerator.html +666 -0
- data/doc/classes/Mack/Data/Field.html +267 -0
- data/doc/classes/Mack/Data/FieldMgr.html +217 -0
- data/doc/classes/Mack/Data/OrmBridge/ActiveRecord.html +267 -0
- data/doc/classes/Mack/Data/OrmBridge/DataMapper.html +267 -0
- data/doc/classes/Mack/Data/OrmBridge/Default.html +266 -0
- data/doc/created.rid +1 -0
- data/doc/files/README.html +107 -0
- data/doc/files/lib/mack-data_factory/content_generator_rb.html +101 -0
- data/doc/files/lib/mack-data_factory/core_extensions/kernel_rb.html +101 -0
- data/doc/files/lib/mack-data_factory/data_factory_rb.html +101 -0
- data/doc/files/lib/mack-data_factory/field_manager_rb.html +101 -0
- data/doc/files/lib/mack-data_factory/field_rb.html +101 -0
- data/doc/files/lib/mack-data_factory/orm_api_bridge/bridge_rb.html +101 -0
- data/doc/files/lib/mack-data_factory/orm_api_bridge/orm/active_record_rb.html +101 -0
- data/doc/files/lib/mack-data_factory/orm_api_bridge/orm/data_mapper_rb.html +101 -0
- data/doc/files/lib/mack-data_factory/orm_api_bridge/orm/default_rb.html +101 -0
- data/doc/files/lib/mack-data_factory_rb.html +108 -0
- data/doc/fr_class_index.html +42 -0
- data/doc/fr_file_index.html +37 -0
- data/doc/fr_method_index.html +78 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- metadata +30 -2
@@ -0,0 +1,267 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Mack::Data::Field</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Mack::Data::Field</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/lib/mack-data_factory/field_rb.html">
|
59
|
+
lib/mack-data_factory/field.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000044">get_value</a>
|
90
|
+
<a href="#M000043">new</a>
|
91
|
+
</div>
|
92
|
+
</div>
|
93
|
+
|
94
|
+
</div>
|
95
|
+
|
96
|
+
|
97
|
+
<!-- if includes -->
|
98
|
+
|
99
|
+
<div id="section">
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
<div id="attribute-list">
|
106
|
+
<h3 class="section-bar">Attributes</h3>
|
107
|
+
|
108
|
+
<div class="name-list">
|
109
|
+
<table>
|
110
|
+
<tr class="top-aligned-row context-row">
|
111
|
+
<td class="context-item-name">field_name</td>
|
112
|
+
<td class="context-item-value"> [RW] </td>
|
113
|
+
<td class="context-item-desc"></td>
|
114
|
+
</tr>
|
115
|
+
<tr class="top-aligned-row context-row">
|
116
|
+
<td class="context-item-name">field_rules</td>
|
117
|
+
<td class="context-item-value"> [RW] </td>
|
118
|
+
<td class="context-item-desc"></td>
|
119
|
+
</tr>
|
120
|
+
<tr class="top-aligned-row context-row">
|
121
|
+
<td class="context-item-name">field_value</td>
|
122
|
+
<td class="context-item-value"> [RW] </td>
|
123
|
+
<td class="context-item-desc"></td>
|
124
|
+
</tr>
|
125
|
+
<tr class="top-aligned-row context-row">
|
126
|
+
<td class="context-item-name">field_value_producer</td>
|
127
|
+
<td class="context-item-value"> [RW] </td>
|
128
|
+
<td class="context-item-desc"></td>
|
129
|
+
</tr>
|
130
|
+
</table>
|
131
|
+
</div>
|
132
|
+
</div>
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
<!-- if method_list -->
|
137
|
+
<div id="methods">
|
138
|
+
<h3 class="section-bar">Public Class methods</h3>
|
139
|
+
|
140
|
+
<div id="method-M000043" class="method-detail">
|
141
|
+
<a name="M000043"></a>
|
142
|
+
|
143
|
+
<div class="method-heading">
|
144
|
+
<a href="#M000043" class="method-signature">
|
145
|
+
<span class="method-name">new</span><span class="method-args">(hash = {})</span>
|
146
|
+
</a>
|
147
|
+
</div>
|
148
|
+
|
149
|
+
<div class="method-description">
|
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">
|
153
|
+
<pre>
|
154
|
+
<span class="ruby-comment cmt"># File lib/mack-data_factory/field.rb, line 13</span>
|
155
|
+
13: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">hash</span> = {})
|
156
|
+
14: <span class="ruby-comment cmt">#puts "Inititalizing DataFactory's Field object:"</span>
|
157
|
+
15:
|
158
|
+
16: <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
159
|
+
17: <span class="ruby-comment cmt">#puts "--> Setting #{v} to #{k}"</span>
|
160
|
+
18: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">"#{k}="</span>, <span class="ruby-identifier">v</span>)
|
161
|
+
19: <span class="ruby-keyword kw">end</span>
|
162
|
+
20:
|
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">></span> <span class="ruby-keyword kw">false</span>,
|
165
|
+
23: <span class="ruby-identifier">:length</span> =<span class="ruby-operator">></span> <span class="ruby-value">256</span>,
|
166
|
+
24: <span class="ruby-identifier">:add_space</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>,
|
167
|
+
25: <span class="ruby-identifier">:content</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:alpha_numeric</span>,
|
168
|
+
26: <span class="ruby-identifier">:null_frequency</span> =<span class="ruby-operator">></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">"#{field_rules[:content]}_generator"</span>)
|
177
|
+
35: <span class="ruby-keyword kw">end</span>
|
178
|
+
</pre>
|
179
|
+
</div>
|
180
|
+
</div>
|
181
|
+
</div>
|
182
|
+
|
183
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
184
|
+
|
185
|
+
<div id="method-M000044" class="method-detail">
|
186
|
+
<a name="M000044"></a>
|
187
|
+
|
188
|
+
<div class="method-heading">
|
189
|
+
<a href="#M000044" class="method-signature">
|
190
|
+
<span class="method-name">get_value</span><span class="method-args">(index = 0)</span>
|
191
|
+
</a>
|
192
|
+
</div>
|
193
|
+
|
194
|
+
<div class="method-description">
|
195
|
+
<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">
|
198
|
+
<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 >= 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">"WARNING: DataFactory: field_value for #{field_name} is not set properly because data relationship defined is not correct"</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>
|
250
|
+
</pre>
|
251
|
+
</div>
|
252
|
+
</div>
|
253
|
+
</div>
|
254
|
+
|
255
|
+
|
256
|
+
</div>
|
257
|
+
|
258
|
+
|
259
|
+
</div>
|
260
|
+
|
261
|
+
|
262
|
+
<div id="validator-badges">
|
263
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
264
|
+
</div>
|
265
|
+
|
266
|
+
</body>
|
267
|
+
</html>
|
@@ -0,0 +1,217 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Mack::Data::FieldMgr</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Mack::Data::FieldMgr</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/lib/mack-data_factory/field_manager_rb.html">
|
59
|
+
lib/mack-data_factory/field_manager.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000041">add</a>
|
90
|
+
<a href="#M000042">fields</a>
|
91
|
+
<a href="#M000040">new</a>
|
92
|
+
</div>
|
93
|
+
</div>
|
94
|
+
|
95
|
+
</div>
|
96
|
+
|
97
|
+
|
98
|
+
<!-- if includes -->
|
99
|
+
|
100
|
+
<div id="section">
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
<div id="attribute-list">
|
107
|
+
<h3 class="section-bar">Attributes</h3>
|
108
|
+
|
109
|
+
<div class="name-list">
|
110
|
+
<table>
|
111
|
+
<tr class="top-aligned-row context-row">
|
112
|
+
<td class="context-item-name">scopes</td>
|
113
|
+
<td class="context-item-value"> [R] </td>
|
114
|
+
<td class="context-item-desc"></td>
|
115
|
+
</tr>
|
116
|
+
</table>
|
117
|
+
</div>
|
118
|
+
</div>
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
<!-- if method_list -->
|
123
|
+
<div id="methods">
|
124
|
+
<h3 class="section-bar">Public Class methods</h3>
|
125
|
+
|
126
|
+
<div id="method-M000040" class="method-detail">
|
127
|
+
<a name="M000040"></a>
|
128
|
+
|
129
|
+
<div class="method-heading">
|
130
|
+
<a href="#M000040" class="method-signature">
|
131
|
+
<span class="method-name">new</span><span class="method-args">()</span>
|
132
|
+
</a>
|
133
|
+
</div>
|
134
|
+
|
135
|
+
<div class="method-description">
|
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">
|
139
|
+
<pre>
|
140
|
+
<span class="ruby-comment cmt"># File lib/mack-data_factory/field_manager.rb, line 6</span>
|
141
|
+
6: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
|
142
|
+
7: <span class="ruby-ivar">@scopes</span> = {}
|
143
|
+
8: <span class="ruby-keyword kw">end</span>
|
144
|
+
</pre>
|
145
|
+
</div>
|
146
|
+
</div>
|
147
|
+
</div>
|
148
|
+
|
149
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
150
|
+
|
151
|
+
<div id="method-M000041" class="method-detail">
|
152
|
+
<a name="M000041"></a>
|
153
|
+
|
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 = {}, &block)</span>
|
157
|
+
</a>
|
158
|
+
</div>
|
159
|
+
|
160
|
+
<div class="method-description">
|
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">
|
164
|
+
<pre>
|
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">&</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">></span> <span class="ruby-identifier">field_name</span>,
|
169
|
+
13: <span class="ruby-identifier">:field_value</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">default_value</span>,
|
170
|
+
14: <span class="ruby-identifier">:field_rules</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">options</span>)
|
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
|
+
16: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">field_list</span>
|
173
|
+
17: <span class="ruby-keyword kw">end</span>
|
174
|
+
</pre>
|
175
|
+
</div>
|
176
|
+
</div>
|
177
|
+
</div>
|
178
|
+
|
179
|
+
<div id="method-M000042" class="method-detail">
|
180
|
+
<a name="M000042"></a>
|
181
|
+
|
182
|
+
<div class="method-heading">
|
183
|
+
<a href="#M000042" class="method-signature">
|
184
|
+
<span class="method-name">fields</span><span class="method-args">(scope = :default)</span>
|
185
|
+
</a>
|
186
|
+
</div>
|
187
|
+
|
188
|
+
<div class="method-description">
|
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">
|
192
|
+
<pre>
|
193
|
+
<span class="ruby-comment cmt"># File lib/mack-data_factory/field_manager.rb, line 19</span>
|
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>)
|
195
|
+
20: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@scopes</span>[<span class="ruby-identifier">scope</span>].<span class="ruby-identifier">nil?</span>
|
196
|
+
21: <span class="ruby-ivar">@scopes</span>[<span class="ruby-identifier">scope</span>] = {}
|
197
|
+
22: <span class="ruby-keyword kw">end</span>
|
198
|
+
23: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@scopes</span>[<span class="ruby-identifier">scope</span>]
|
199
|
+
24: <span class="ruby-keyword kw">end</span>
|
200
|
+
</pre>
|
201
|
+
</div>
|
202
|
+
</div>
|
203
|
+
</div>
|
204
|
+
|
205
|
+
|
206
|
+
</div>
|
207
|
+
|
208
|
+
|
209
|
+
</div>
|
210
|
+
|
211
|
+
|
212
|
+
<div id="validator-badges">
|
213
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
214
|
+
</div>
|
215
|
+
|
216
|
+
</body>
|
217
|
+
</html>
|