mack-data_factory 0.7.1 → 0.7.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mack-data_factory/content_generator.rb +1 -1
- data/lib/mack-data_factory/core_extensions/kernel.rb +13 -17
- data/lib/mack-data_factory/data_factory.rb +128 -19
- data/lib/mack-data_factory/field.rb +1 -1
- data/lib/mack-data_factory/field_manager.rb +1 -1
- data/lib/mack-data_factory/orm_api_bridge/bridge.rb +69 -1
- data/lib/mack-data_factory/orm_api_bridge/orm/active_record.rb +2 -2
- data/lib/mack-data_factory/orm_api_bridge/orm/data_mapper.rb +2 -2
- data/lib/mack-data_factory/orm_api_bridge/orm/default.rb +1 -1
- metadata +2 -30
- data/doc/classes/Kernel.html +0 -207
- data/doc/classes/Mack.html +0 -137
- data/doc/classes/Mack/Data/Bridge.html +0 -269
- data/doc/classes/Mack/Data/Factory.html +0 -171
- data/doc/classes/Mack/Data/Factory/ClassMethods.html +0 -290
- data/doc/classes/Mack/Data/Factory/FieldContentGenerator.html +0 -685
- data/doc/classes/Mack/Data/Field.html +0 -271
- data/doc/classes/Mack/Data/FieldMgr.html +0 -217
- data/doc/classes/Mack/Data/OrmBridge/ActiveRecord.html +0 -267
- data/doc/classes/Mack/Data/OrmBridge/DataMapper.html +0 -267
- data/doc/classes/Mack/Data/OrmBridge/Default.html +0 -266
- data/doc/created.rid +0 -1
- data/doc/files/README.html +0 -107
- data/doc/files/lib/mack-data_factory/content_generator_rb.html +0 -108
- data/doc/files/lib/mack-data_factory/core_extensions/kernel_rb.html +0 -101
- data/doc/files/lib/mack-data_factory/data_factory_rb.html +0 -101
- data/doc/files/lib/mack-data_factory/field_manager_rb.html +0 -101
- data/doc/files/lib/mack-data_factory/field_rb.html +0 -101
- data/doc/files/lib/mack-data_factory/orm_api_bridge/bridge_rb.html +0 -101
- data/doc/files/lib/mack-data_factory/orm_api_bridge/orm/active_record_rb.html +0 -101
- data/doc/files/lib/mack-data_factory/orm_api_bridge/orm/data_mapper_rb.html +0 -101
- data/doc/files/lib/mack-data_factory/orm_api_bridge/orm/default_rb.html +0 -101
- data/doc/files/lib/mack-data_factory_rb.html +0 -108
- data/doc/fr_class_index.html +0 -37
- data/doc/fr_file_index.html +0 -37
- data/doc/fr_method_index.html +0 -79
- data/doc/index.html +0 -24
- data/doc/rdoc-style.css +0 -208
@@ -1,171 +0,0 @@
|
|
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>Module: Mack::Data::Factory</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>Module</strong></td>
|
53
|
-
<td class="class-name-in-header">Mack::Data::Factory</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/content_generator_rb.html">
|
59
|
-
lib/mack-data_factory/content_generator.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
<a href="../../../files/lib/mack-data_factory/data_factory_rb.html">
|
63
|
-
lib/mack-data_factory/data_factory.rb
|
64
|
-
</a>
|
65
|
-
<br />
|
66
|
-
</td>
|
67
|
-
</tr>
|
68
|
-
|
69
|
-
</table>
|
70
|
-
</div>
|
71
|
-
<!-- banner header -->
|
72
|
-
|
73
|
-
<div id="bodyContent">
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
<div id="contextContent">
|
78
|
-
|
79
|
-
<div id="description">
|
80
|
-
<p>
|
81
|
-
Add factory capability to a class.
|
82
|
-
</p>
|
83
|
-
<p>
|
84
|
-
A factory is able to define which field it want to generate content for,
|
85
|
-
define a scope for different situation, and set a custom content generator
|
86
|
-
for field that doesn‘t want to use the default content generator.
|
87
|
-
</p>
|
88
|
-
<p>
|
89
|
-
For more information and usage, please read README file
|
90
|
-
</p>
|
91
|
-
<p>
|
92
|
-
author: Darsono Sutedja July 2008
|
93
|
-
</p>
|
94
|
-
|
95
|
-
</div>
|
96
|
-
|
97
|
-
|
98
|
-
</div>
|
99
|
-
|
100
|
-
<div id="method-list">
|
101
|
-
<h3 class="section-bar">Methods</h3>
|
102
|
-
|
103
|
-
<div class="name-list">
|
104
|
-
<a href="#M000001">included</a>
|
105
|
-
</div>
|
106
|
-
</div>
|
107
|
-
|
108
|
-
</div>
|
109
|
-
|
110
|
-
|
111
|
-
<!-- if includes -->
|
112
|
-
|
113
|
-
<div id="section">
|
114
|
-
|
115
|
-
<div id="class-list">
|
116
|
-
<h3 class="section-bar">Classes and Modules</h3>
|
117
|
-
|
118
|
-
Module <a href="Factory/ClassMethods.html" class="link">Mack::Data::Factory::ClassMethods</a><br />
|
119
|
-
Class <a href="Factory/FieldContentGenerator.html" class="link">Mack::Data::Factory::FieldContentGenerator</a><br />
|
120
|
-
|
121
|
-
</div>
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
<!-- if method_list -->
|
130
|
-
<div id="methods">
|
131
|
-
<h3 class="section-bar">Public Class methods</h3>
|
132
|
-
|
133
|
-
<div id="method-M000001" class="method-detail">
|
134
|
-
<a name="M000001"></a>
|
135
|
-
|
136
|
-
<div class="method-heading">
|
137
|
-
<a href="#M000001" class="method-signature">
|
138
|
-
<span class="method-name">included</span><span class="method-args">(base)</span>
|
139
|
-
</a>
|
140
|
-
</div>
|
141
|
-
|
142
|
-
<div class="method-description">
|
143
|
-
<p>
|
144
|
-
make sure the data factory API is available to the class that includes it
|
145
|
-
</p>
|
146
|
-
<p><a class="source-toggle" href="#"
|
147
|
-
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
148
|
-
<div class="method-source-code" id="M000001-source">
|
149
|
-
<pre>
|
150
|
-
<span class="ruby-comment cmt"># File lib/mack-data_factory/data_factory.rb, line 18</span>
|
151
|
-
18: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">included</span>(<span class="ruby-identifier">base</span>)
|
152
|
-
19: <span class="ruby-identifier">base</span>.<span class="ruby-identifier">extend</span> <span class="ruby-constant">ClassMethods</span>
|
153
|
-
20: <span class="ruby-keyword kw">end</span>
|
154
|
-
</pre>
|
155
|
-
</div>
|
156
|
-
</div>
|
157
|
-
</div>
|
158
|
-
|
159
|
-
|
160
|
-
</div>
|
161
|
-
|
162
|
-
|
163
|
-
</div>
|
164
|
-
|
165
|
-
|
166
|
-
<div id="validator-badges">
|
167
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
168
|
-
</div>
|
169
|
-
|
170
|
-
</body>
|
171
|
-
</html>
|
@@ -1,290 +0,0 @@
|
|
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>Module: Mack::Data::Factory::ClassMethods</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>Module</strong></td>
|
53
|
-
<td class="class-name-in-header">Mack::Data::Factory::ClassMethods</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/data_factory_rb.html">
|
59
|
-
lib/mack-data_factory/data_factory.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
</table>
|
66
|
-
</div>
|
67
|
-
<!-- banner header -->
|
68
|
-
|
69
|
-
<div id="bodyContent">
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
<div id="contextContent">
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
</div>
|
78
|
-
|
79
|
-
<div id="method-list">
|
80
|
-
<h3 class="section-bar">Methods</h3>
|
81
|
-
|
82
|
-
<div class="name-list">
|
83
|
-
<a href="#M000004">association</a>
|
84
|
-
<a href="#M000002">create</a>
|
85
|
-
<a href="#M000003">field</a>
|
86
|
-
<a href="#M000005">scope_for</a>
|
87
|
-
</div>
|
88
|
-
</div>
|
89
|
-
|
90
|
-
</div>
|
91
|
-
|
92
|
-
|
93
|
-
<!-- if includes -->
|
94
|
-
|
95
|
-
<div id="section">
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
<!-- if method_list -->
|
105
|
-
<div id="methods">
|
106
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
107
|
-
|
108
|
-
<div id="method-M000004" class="method-detail">
|
109
|
-
<a name="M000004"></a>
|
110
|
-
|
111
|
-
<div class="method-heading">
|
112
|
-
<a href="#M000004" class="method-signature">
|
113
|
-
<span class="method-name">association</span><span class="method-args">(model_attrib_sym, assoc_map, assoc_rule = :spread)</span>
|
114
|
-
</a>
|
115
|
-
</div>
|
116
|
-
|
117
|
-
<div class="method-description">
|
118
|
-
<p>
|
119
|
-
Define an <a href="ClassMethods.html#M000004">association</a> rule for this
|
120
|
-
<a href="ClassMethods.html#M000003">field</a>
|
121
|
-
</p>
|
122
|
-
<p><a class="source-toggle" href="#"
|
123
|
-
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
124
|
-
<div class="method-source-code" id="M000004-source">
|
125
|
-
<pre>
|
126
|
-
<span class="ruby-comment cmt"># File lib/mack-data_factory/data_factory.rb, line 88</span>
|
127
|
-
88: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">association</span>(<span class="ruby-identifier">model_attrib_sym</span>, <span class="ruby-identifier">assoc_map</span>, <span class="ruby-identifier">assoc_rule</span> = <span class="ruby-identifier">:spread</span>)
|
128
|
-
89: <span class="ruby-identifier">field</span>(<span class="ruby-identifier">model_attrib_sym</span>, {<span class="ruby-identifier">:default</span> =<span class="ruby-operator">></span> {<span class="ruby-identifier">:df_assoc_map</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">assoc_map</span>}, <span class="ruby-identifier">:assoc</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">assoc_rule</span>})
|
129
|
-
90: <span class="ruby-keyword kw">end</span>
|
130
|
-
</pre>
|
131
|
-
</div>
|
132
|
-
</div>
|
133
|
-
</div>
|
134
|
-
|
135
|
-
<div id="method-M000002" class="method-detail">
|
136
|
-
<a name="M000002"></a>
|
137
|
-
|
138
|
-
<div class="method-heading">
|
139
|
-
<a href="#M000002" class="method-signature">
|
140
|
-
<span class="method-name">create</span><span class="method-args">(num, scope = :default)</span>
|
141
|
-
</a>
|
142
|
-
</div>
|
143
|
-
|
144
|
-
<div class="method-description">
|
145
|
-
<p>
|
146
|
-
Run the factory to produce n number of objects.
|
147
|
-
</p>
|
148
|
-
<p>
|
149
|
-
Example: class CarFactory
|
150
|
-
</p>
|
151
|
-
<pre>
|
152
|
-
include Mack::Data::Factory
|
153
|
-
field :name, :default => "honda" { |def_value, rules, index| "#{def_value} #{['civic', 'accord', 'pilot'].randomize[0]}"}
|
154
|
-
</pre>
|
155
|
-
<p>
|
156
|
-
end
|
157
|
-
</p>
|
158
|
-
<p>
|
159
|
-
CarFactory.create(100) #=> will produce 100 cars whose name is
|
160
|
-
"honda xxx" where xxx is a random item from [‘civic’,
|
161
|
-
‘accord’, ‘pilot’]
|
162
|
-
</p>
|
163
|
-
<p>
|
164
|
-
params:
|
165
|
-
</p>
|
166
|
-
<ul>
|
167
|
-
<li>num - how many objects to produce
|
168
|
-
|
169
|
-
</li>
|
170
|
-
<li>scope - run the factory in a named scope
|
171
|
-
|
172
|
-
</li>
|
173
|
-
</ul>
|
174
|
-
<p><a class="source-toggle" href="#"
|
175
|
-
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
176
|
-
<div class="method-source-code" id="M000002-source">
|
177
|
-
<pre>
|
178
|
-
<span class="ruby-comment cmt"># File lib/mack-data_factory/data_factory.rb, line 39</span>
|
179
|
-
39: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create</span>(<span class="ruby-identifier">num</span>, <span class="ruby-identifier">scope</span> = <span class="ruby-identifier">:default</span>)
|
180
|
-
40: <span class="ruby-identifier">factory_name</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">underscore</span>
|
181
|
-
41:
|
182
|
-
42: <span class="ruby-comment cmt"># retrieve the model name from the factory class. </span>
|
183
|
-
43: <span class="ruby-identifier">model_name</span> = <span class="ruby-identifier">factory_name</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">'_factory'</span>, <span class="ruby-value str">''</span>)
|
184
|
-
44:
|
185
|
-
45: <span class="ruby-comment cmt"># if user is running custom scope, then merge the fields </span>
|
186
|
-
46: <span class="ruby-comment cmt"># defined for that scope with the default one, before we run the factory</span>
|
187
|
-
47: <span class="ruby-identifier">scoped_fields</span> = <span class="ruby-identifier">field_manager</span>.<span class="ruby-identifier">scopes</span>[<span class="ruby-identifier">scope</span>]
|
188
|
-
48: <span class="ruby-identifier">fields</span> = <span class="ruby-identifier">field_manager</span>.<span class="ruby-identifier">scopes</span>[<span class="ruby-identifier">:default</span>].<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">scoped_fields</span>)
|
189
|
-
49:
|
190
|
-
50: <span class="ruby-identifier">ret_arr</span> = []
|
191
|
-
51:
|
192
|
-
52: <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">reset!</span>
|
193
|
-
53: <span class="ruby-identifier">num</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
194
|
-
54: <span class="ruby-comment cmt">#puts "Creating #{model_name} ##{i+1}"</span>
|
195
|
-
55: <span class="ruby-identifier">obj</span> = <span class="ruby-identifier">model_name</span>.<span class="ruby-identifier">camelcase</span>.<span class="ruby-identifier">constantize</span>.<span class="ruby-identifier">new</span>
|
196
|
-
56:
|
197
|
-
57: <span class="ruby-identifier">fields</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>
|
198
|
-
58: <span class="ruby-identifier">field_name</span> = <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_s</span>
|
199
|
-
59: <span class="ruby-identifier">field_value</span> = <span class="ruby-identifier">v</span>.<span class="ruby-identifier">get_value</span>(<span class="ruby-identifier">i</span>)
|
200
|
-
60: <span class="ruby-identifier">assert_method</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-node">"#{field_name}="</span>, <span class="ruby-node">"#{model_name.camelcase} doesn't have #{field_name}= method!"</span>) <span class="ruby-keyword kw">do</span>
|
201
|
-
61: <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">"#{field_name}="</span>, <span class="ruby-identifier">field_value</span>)
|
202
|
-
62: <span class="ruby-keyword kw">end</span>
|
203
|
-
63: <span class="ruby-keyword kw">end</span>
|
204
|
-
64:
|
205
|
-
65: <span class="ruby-identifier">assert_method</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-value str">"save"</span>, <span class="ruby-node">"#{model_name.camelcase} doesn't have save method. Data will not be saved!"</span>) <span class="ruby-keyword kw">do</span>
|
206
|
-
66: <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">save</span>
|
207
|
-
67: <span class="ruby-keyword kw">end</span>
|
208
|
-
68:
|
209
|
-
69: <span class="ruby-identifier">ret_arr</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">obj</span>
|
210
|
-
70: <span class="ruby-keyword kw">end</span>
|
211
|
-
71: <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">reset!</span>
|
212
|
-
72:
|
213
|
-
73: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">ret_arr</span>[<span class="ruby-value">0</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">ret_arr</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
214
|
-
74: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">ret_arr</span>
|
215
|
-
75: <span class="ruby-keyword kw">end</span>
|
216
|
-
</pre>
|
217
|
-
</div>
|
218
|
-
</div>
|
219
|
-
</div>
|
220
|
-
|
221
|
-
<div id="method-M000003" class="method-detail">
|
222
|
-
<a name="M000003"></a>
|
223
|
-
|
224
|
-
<div class="method-heading">
|
225
|
-
<a href="#M000003" class="method-signature">
|
226
|
-
<span class="method-name">field</span><span class="method-args">(model_attrib_sym, options = {}, &block)</span>
|
227
|
-
</a>
|
228
|
-
</div>
|
229
|
-
|
230
|
-
<div class="method-description">
|
231
|
-
<p>
|
232
|
-
Define a <a href="ClassMethods.html#M000003">field</a> with its default
|
233
|
-
value and rules and an optional content generator for this factory
|
234
|
-
</p>
|
235
|
-
<p><a class="source-toggle" href="#"
|
236
|
-
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
237
|
-
<div class="method-source-code" id="M000003-source">
|
238
|
-
<pre>
|
239
|
-
<span class="ruby-comment cmt"># File lib/mack-data_factory/data_factory.rb, line 81</span>
|
240
|
-
81: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">field</span>(<span class="ruby-identifier">model_attrib_sym</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
241
|
-
82: <span class="ruby-identifier">field_manager</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">scope</span>, <span class="ruby-identifier">model_attrib_sym</span>, <span class="ruby-identifier">options</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
242
|
-
83: <span class="ruby-keyword kw">end</span>
|
243
|
-
</pre>
|
244
|
-
</div>
|
245
|
-
</div>
|
246
|
-
</div>
|
247
|
-
|
248
|
-
<div id="method-M000005" class="method-detail">
|
249
|
-
<a name="M000005"></a>
|
250
|
-
|
251
|
-
<div class="method-heading">
|
252
|
-
<a href="#M000005" class="method-signature">
|
253
|
-
<span class="method-name">scope_for</span><span class="method-args">(tag) {|| ...}</span>
|
254
|
-
</a>
|
255
|
-
</div>
|
256
|
-
|
257
|
-
<div class="method-description">
|
258
|
-
<p>
|
259
|
-
Define a scope in the factory. Any <a
|
260
|
-
href="ClassMethods.html#M000003">field</a> defined in a scope will
|
261
|
-
overwrite its cousin in the default scope.
|
262
|
-
</p>
|
263
|
-
<p><a class="source-toggle" href="#"
|
264
|
-
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
265
|
-
<div class="method-source-code" id="M000005-source">
|
266
|
-
<pre>
|
267
|
-
<span class="ruby-comment cmt"># File lib/mack-data_factory/data_factory.rb, line 96</span>
|
268
|
-
96: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">scope_for</span>(<span class="ruby-identifier">tag</span>)
|
269
|
-
97: <span class="ruby-identifier">set_scope</span>(<span class="ruby-identifier">tag</span>)
|
270
|
-
98: <span class="ruby-keyword kw">yield</span>
|
271
|
-
99: <span class="ruby-identifier">set_scope</span>(<span class="ruby-identifier">:default</span>)
|
272
|
-
100: <span class="ruby-keyword kw">end</span>
|
273
|
-
</pre>
|
274
|
-
</div>
|
275
|
-
</div>
|
276
|
-
</div>
|
277
|
-
|
278
|
-
|
279
|
-
</div>
|
280
|
-
|
281
|
-
|
282
|
-
</div>
|
283
|
-
|
284
|
-
|
285
|
-
<div id="validator-badges">
|
286
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
287
|
-
</div>
|
288
|
-
|
289
|
-
</body>
|
290
|
-
</html>
|