sofa 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/.yardopts +6 -0
- data/LICENSE +20 -0
- data/README.md +72 -0
- data/Rakefile +76 -0
- data/doc/Sofa.html +85 -0
- data/doc/Sofa/Mapping.html +168 -0
- data/doc/Sofa/Mapping/ClassMethods.html +314 -0
- data/doc/Sofa/Mapping/InstanceMethods.html +358 -0
- data/doc/Sofa/TVRage.html +85 -0
- data/doc/Sofa/TVRage/Episode.html +358 -0
- data/doc/Sofa/TVRage/Schedule.html +207 -0
- data/doc/Sofa/TVRage/Season.html +236 -0
- data/doc/Sofa/TVRage/Show.html +904 -0
- data/doc/Sofa/TVRage/Show/ShowNotFound.html +92 -0
- data/doc/Sofa/Version.html +100 -0
- data/doc/_index.html +206 -0
- data/doc/class_list.html +137 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +23 -0
- data/doc/css/style.css +261 -0
- data/doc/file.README.html +120 -0
- data/doc/file_list.html +29 -0
- data/doc/index.html +120 -0
- data/doc/js/app.js +91 -0
- data/doc/js/full_list.js +39 -0
- data/doc/js/jquery.js +19 -0
- data/doc/method_list.html +192 -0
- data/doc/top-level-namespace.html +80 -0
- data/lib/sofa.rb +5 -0
- data/lib/sofa/mapping.rb +108 -0
- data/lib/sofa/tvrage.rb +10 -0
- data/lib/sofa/tvrage/episode.rb +39 -0
- data/lib/sofa/tvrage/schedule.rb +25 -0
- data/lib/sofa/tvrage/season.rb +36 -0
- data/lib/sofa/tvrage/show.rb +132 -0
- data/lib/sofa/version.rb +8 -0
- data/sofa.gemspec +126 -0
- data/spec/fixtures/tvrage/cases/castle.xml +228 -0
- data/spec/fixtures/tvrage/cases/community.xml +109 -0
- data/spec/fixtures/tvrage/cases/live_with_regis_and_kelly.xml +56237 -0
- data/spec/fixtures/tvrage/episode_list.xml +1183 -0
- data/spec/fixtures/tvrage/episode_list_one_season.xml +17 -0
- data/spec/fixtures/tvrage/episode_list_two_episodes.xml +25 -0
- data/spec/fixtures/tvrage/full_schedule.xml +4731 -0
- data/spec/fixtures/tvrage/full_show_info.xml +1291 -0
- data/spec/fixtures/tvrage/quickinfo.html +17 -0
- data/spec/fixtures/tvrage/quickinfo_missing.html +1 -0
- data/spec/fixtures/tvrage/search.xml +151 -0
- data/spec/fixtures/tvrage/show_info.xml +42 -0
- data/spec/fixtures/tvrage/show_info_blank.xml +3 -0
- data/spec/fixtures/tvrage/single_episode.xml +8 -0
- data/spec/sofa/mapping_spec.rb +82 -0
- data/spec/sofa/tvrage/cases_spec.rb +29 -0
- data/spec/sofa/tvrage/episode_spec.rb +45 -0
- data/spec/sofa/tvrage/schedule_spec.rb +17 -0
- data/spec/sofa/tvrage/season_spec.rb +61 -0
- data/spec/sofa/tvrage/show_spec.rb +162 -0
- data/spec/sofa/version_spec.rb +11 -0
- data/spec/sofa_spec.rb +5 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +14 -0
- metadata +175 -0
@@ -0,0 +1,314 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta name="Content-Type" content="text/html; charset=UTF-8" />
|
6
|
+
<title>Module: Sofa::Mapping::ClassMethods</title>
|
7
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
+
|
10
|
+
<script type="text/javascript" charset="utf-8">
|
11
|
+
relpath = '../..';
|
12
|
+
if (relpath != '') relpath += '/';
|
13
|
+
</script>
|
14
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
15
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<div id="header">
|
20
|
+
<div id="menu">
|
21
|
+
|
22
|
+
<a href="../../_index.html">Index (C)</a> »
|
23
|
+
<a title="Sofa" href="../../Sofa.html">Sofa</a> » <a title="Mapping" href="../Mapping.html">Mapping</a>
|
24
|
+
»
|
25
|
+
<span class="title">ClassMethods</span>
|
26
|
+
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div id="search">
|
30
|
+
<a id="class_list_link" href="#">Namespace List</a>
|
31
|
+
<a id="method_list_link" href="#">Method List</a>
|
32
|
+
<a id ="file_list_link" href="#">File List</a>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div class="clear"></div>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<iframe id="search_frame"></iframe>
|
39
|
+
|
40
|
+
<div id="content"><h1>Module: Sofa::Mapping::ClassMethods
|
41
|
+
|
42
|
+
|
43
|
+
</h1>
|
44
|
+
|
45
|
+
<dl class="box">
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
<dt class="r1 last">Defined in:</dt>
|
54
|
+
<dd class="r1 last">lib/sofa/mapping.rb</dd>
|
55
|
+
|
56
|
+
</dl>
|
57
|
+
<div class="clear"></div>
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
<h2>Method Summary</h2>
|
63
|
+
<ul class="summary">
|
64
|
+
|
65
|
+
<li class="public ">
|
66
|
+
<span class="summary_signature"><a title="#mappings (instance method)" href="#mappings-instance_method">- (Hash<Symbol, Symbol>) <strong>mappings</strong> </a>
|
67
|
+
|
68
|
+
</span>
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
<span class="summary_desc">Mapping of symbols to attribute names.</span>
|
76
|
+
|
77
|
+
</li>
|
78
|
+
|
79
|
+
|
80
|
+
<li class="public ">
|
81
|
+
<span class="summary_signature"><a title="#mappings_procs (instance method)" href="#mappings_procs-instance_method">- (Hash<Symbol, Proc>) <strong>mappings_procs</strong> </a>
|
82
|
+
|
83
|
+
</span>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
<span class="summary_desc">Mapping of attribute names to a Proc filter.</span>
|
91
|
+
|
92
|
+
</li>
|
93
|
+
|
94
|
+
|
95
|
+
<li class="public ">
|
96
|
+
<span class="summary_signature"><a title="#maps (instance method)" href="#maps-instance_method">- (Object) <strong>maps</strong>(hash = {}, &block) </a>
|
97
|
+
|
98
|
+
</span>
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
<span class="summary_desc">Class method to define mappings.</span>
|
106
|
+
|
107
|
+
</li>
|
108
|
+
|
109
|
+
|
110
|
+
</ul>
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
<div id="method_details">
|
115
|
+
<h2>Method Details</h2>
|
116
|
+
|
117
|
+
<div class="method_details first">
|
118
|
+
<p class="signature first" id="mappings-instance_method">
|
119
|
+
|
120
|
+
- (<tt>Hash<Symbol, Symbol></tt>) <strong>mappings</strong>
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
</p><div class="docstring">
|
125
|
+
<div class="discussion">
|
126
|
+
<p>Mapping of symbols to attribute names</p>
|
127
|
+
|
128
|
+
</div>
|
129
|
+
</div>
|
130
|
+
<div class="tags">
|
131
|
+
<h3>Returns:</h3>
|
132
|
+
<ul class="return">
|
133
|
+
|
134
|
+
<li>
|
135
|
+
|
136
|
+
<span class='type'>(<tt>Hash<Symbol, Symbol></tt>)</span>
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
—
|
142
|
+
Mapping of symbols to attribute names
|
143
|
+
|
144
|
+
</li>
|
145
|
+
|
146
|
+
</ul>
|
147
|
+
|
148
|
+
</div><table class="source_code">
|
149
|
+
<tr>
|
150
|
+
<td>
|
151
|
+
<pre class="lines">
|
152
|
+
|
153
|
+
|
154
|
+
96
|
155
|
+
97
|
156
|
+
98</pre>
|
157
|
+
</td>
|
158
|
+
<td>
|
159
|
+
<pre class="code"><span class="info file"># File 'lib/sofa/mapping.rb', line 96</span>
|
160
|
+
|
161
|
+
def mappings
|
162
|
+
@mappings
|
163
|
+
end</pre>
|
164
|
+
</td>
|
165
|
+
</tr>
|
166
|
+
</table>
|
167
|
+
</div>
|
168
|
+
|
169
|
+
<div class="method_details ">
|
170
|
+
<p class="signature " id="mappings_procs-instance_method">
|
171
|
+
|
172
|
+
- (<tt>Hash<Symbol, Proc></tt>) <strong>mappings_procs</strong>
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
</p><div class="docstring">
|
177
|
+
<div class="discussion">
|
178
|
+
<p>Mapping of attribute names to a Proc filter.</p>
|
179
|
+
|
180
|
+
</div>
|
181
|
+
</div>
|
182
|
+
<div class="tags">
|
183
|
+
<h3>Returns:</h3>
|
184
|
+
<ul class="return">
|
185
|
+
|
186
|
+
<li>
|
187
|
+
|
188
|
+
<span class='type'>(<tt>Hash<Symbol, Proc></tt>)</span>
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
—
|
194
|
+
Mapping of attribute names to a Proc filter.
|
195
|
+
|
196
|
+
</li>
|
197
|
+
|
198
|
+
</ul>
|
199
|
+
|
200
|
+
<h3>See Also:</h3>
|
201
|
+
<ul class="see">
|
202
|
+
|
203
|
+
<li><a title="#maps" href="#maps-instance_method">#maps</a></li>
|
204
|
+
|
205
|
+
</ul>
|
206
|
+
|
207
|
+
</div><table class="source_code">
|
208
|
+
<tr>
|
209
|
+
<td>
|
210
|
+
<pre class="lines">
|
211
|
+
|
212
|
+
|
213
|
+
103
|
214
|
+
104
|
215
|
+
105</pre>
|
216
|
+
</td>
|
217
|
+
<td>
|
218
|
+
<pre class="code"><span class="info file"># File 'lib/sofa/mapping.rb', line 103</span>
|
219
|
+
|
220
|
+
def mappings_procs
|
221
|
+
@mappings_procs
|
222
|
+
end</pre>
|
223
|
+
</td>
|
224
|
+
</tr>
|
225
|
+
</table>
|
226
|
+
</div>
|
227
|
+
|
228
|
+
<div class="method_details ">
|
229
|
+
<p class="signature " id="maps-instance_method">
|
230
|
+
|
231
|
+
- (<tt>Object</tt>) <strong>maps</strong>(hash = {}, &block)
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
</p><div class="docstring">
|
236
|
+
<div class="discussion">
|
237
|
+
<p>Class method to define mappings.</p>
|
238
|
+
|
239
|
+
</div>
|
240
|
+
</div>
|
241
|
+
<div class="tags">
|
242
|
+
|
243
|
+
<div class="examples">
|
244
|
+
<h3>Examples:</h3>
|
245
|
+
|
246
|
+
<h4>Maps :examplename to :name and :link to itself.</h4>
|
247
|
+
<pre class="example code"> class Example1
|
248
|
+
include Sofa::Mapping
|
249
|
+
maps(
|
250
|
+
:examplename => :name,
|
251
|
+
:link => nil
|
252
|
+
)
|
253
|
+
end
|
254
|
+
example1 = Example1.new.update_with_mapping(:epnum => "1", :link => "http://google.com")
|
255
|
+
example1.name # => "1"
|
256
|
+
example1.link # => "http://google.com"
|
257
|
+
example1.attributes # => {:name => "1", :link => "http://google.com"}</pre>
|
258
|
+
|
259
|
+
<h4>Maps :airdate to :air_date and stores the block.</h4>
|
260
|
+
<pre class="example code"> class Example2
|
261
|
+
include Sofa::Mapping
|
262
|
+
|
263
|
+
maps(:airdate => :air_date) do |value|
|
264
|
+
Date.parse(value)
|
265
|
+
end
|
266
|
+
end
|
267
|
+
example2 = Example2.new.update_with_mapping(:airdate => "2007-07-04")
|
268
|
+
example2.attributes # => {:air_date => Wed, 04 Jul 2007}</pre>
|
269
|
+
|
270
|
+
</div>
|
271
|
+
|
272
|
+
</div><table class="source_code">
|
273
|
+
<tr>
|
274
|
+
<td>
|
275
|
+
<pre class="lines">
|
276
|
+
|
277
|
+
|
278
|
+
85
|
279
|
+
86
|
280
|
+
87
|
281
|
+
88
|
282
|
+
89
|
283
|
+
90
|
284
|
+
91
|
285
|
+
92</pre>
|
286
|
+
</td>
|
287
|
+
<td>
|
288
|
+
<pre class="code"><span class="info file"># File 'lib/sofa/mapping.rb', line 85</span>
|
289
|
+
|
290
|
+
def maps(hash = {}, &block)
|
291
|
+
hash.each do |from, to|
|
292
|
+
method = to || from
|
293
|
+
@mappings[from.to_sym] = method
|
294
|
+
attr_reader method
|
295
|
+
@mappings_procs[method] = block
|
296
|
+
end
|
297
|
+
end</pre>
|
298
|
+
</td>
|
299
|
+
</tr>
|
300
|
+
</table>
|
301
|
+
</div>
|
302
|
+
|
303
|
+
</div>
|
304
|
+
|
305
|
+
</div>
|
306
|
+
|
307
|
+
<div id="footer">
|
308
|
+
Generated on Sat Nov 21 20:13:52 2009 by
|
309
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool">yard</a>
|
310
|
+
0.4.0 (ruby-1.8.7).
|
311
|
+
</div>
|
312
|
+
|
313
|
+
</body>
|
314
|
+
</html>
|
@@ -0,0 +1,358 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta name="Content-Type" content="text/html; charset=UTF-8" />
|
6
|
+
<title>Module: Sofa::Mapping::InstanceMethods</title>
|
7
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
+
|
10
|
+
<script type="text/javascript" charset="utf-8">
|
11
|
+
relpath = '../..';
|
12
|
+
if (relpath != '') relpath += '/';
|
13
|
+
</script>
|
14
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
15
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<div id="header">
|
20
|
+
<div id="menu">
|
21
|
+
|
22
|
+
<a href="../../_index.html">Index (I)</a> »
|
23
|
+
<a title="Sofa" href="../../Sofa.html">Sofa</a> » <a title="Mapping" href="../Mapping.html">Mapping</a>
|
24
|
+
»
|
25
|
+
<span class="title">InstanceMethods</span>
|
26
|
+
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div id="search">
|
30
|
+
<a id="class_list_link" href="#">Namespace List</a>
|
31
|
+
<a id="method_list_link" href="#">Method List</a>
|
32
|
+
<a id ="file_list_link" href="#">File List</a>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div class="clear"></div>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<iframe id="search_frame"></iframe>
|
39
|
+
|
40
|
+
<div id="content"><h1>Module: Sofa::Mapping::InstanceMethods
|
41
|
+
|
42
|
+
|
43
|
+
</h1>
|
44
|
+
|
45
|
+
<dl class="box">
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
<dt class="r1 last">Defined in:</dt>
|
54
|
+
<dd class="r1 last">lib/sofa/mapping.rb</dd>
|
55
|
+
|
56
|
+
</dl>
|
57
|
+
<div class="clear"></div>
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
<h2>Method Summary</h2>
|
63
|
+
<ul class="summary">
|
64
|
+
|
65
|
+
<li class="public ">
|
66
|
+
<span class="summary_signature"><a title="#== (instance method)" href="#%3D%3D-instance_method">- (Boolean) <strong>==</strong>(obj) </a>
|
67
|
+
|
68
|
+
</span>
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
<span class="summary_desc">Compares two objects based on their attributes.</span>
|
76
|
+
|
77
|
+
</li>
|
78
|
+
|
79
|
+
|
80
|
+
<li class="public ">
|
81
|
+
<span class="summary_signature"><a title="#attributes (instance method)" href="#attributes-instance_method">- (Hash<Symbol, Object>) <strong>attributes</strong> </a>
|
82
|
+
|
83
|
+
</span>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
<span class="summary_desc">Returns hash of all the attributes, with attribute names as keys and attribute values as values.</span>
|
91
|
+
|
92
|
+
</li>
|
93
|
+
|
94
|
+
|
95
|
+
<li class="public ">
|
96
|
+
<span class="summary_signature"><a title="#update_with_mapping (instance method)" href="#update_with_mapping-instance_method">- (Object) <strong>update_with_mapping</strong>(attributes = {}) </a>
|
97
|
+
|
98
|
+
</span>
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
<span class="summary_desc">Updates all the attributes from the Hash.</span>
|
106
|
+
|
107
|
+
</li>
|
108
|
+
|
109
|
+
|
110
|
+
</ul>
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
<div id="method_details">
|
115
|
+
<h2>Method Details</h2>
|
116
|
+
|
117
|
+
<div class="method_details first">
|
118
|
+
<p class="signature first" id="==-instance_method">
|
119
|
+
|
120
|
+
- (<tt>Boolean</tt>) <strong>==</strong>(obj)
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
</p><div class="docstring">
|
125
|
+
<div class="discussion">
|
126
|
+
<p>Compares two objects based on their attributes.</p>
|
127
|
+
|
128
|
+
</div>
|
129
|
+
</div>
|
130
|
+
<div class="tags">
|
131
|
+
<h3>Parameters:</h3>
|
132
|
+
<ul class="param">
|
133
|
+
|
134
|
+
<li>
|
135
|
+
|
136
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
137
|
+
|
138
|
+
|
139
|
+
<span class='name'>obj</span>
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
—
|
144
|
+
The object to compare with
|
145
|
+
|
146
|
+
</li>
|
147
|
+
|
148
|
+
</ul>
|
149
|
+
<h3>Returns:</h3>
|
150
|
+
<ul class="return">
|
151
|
+
|
152
|
+
<li>
|
153
|
+
|
154
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
—
|
160
|
+
Whether all attributes are the same
|
161
|
+
|
162
|
+
</li>
|
163
|
+
|
164
|
+
</ul>
|
165
|
+
|
166
|
+
</div><table class="source_code">
|
167
|
+
<tr>
|
168
|
+
<td>
|
169
|
+
<pre class="lines">
|
170
|
+
|
171
|
+
|
172
|
+
48
|
173
|
+
49
|
174
|
+
50
|
175
|
+
51
|
176
|
+
52
|
177
|
+
53
|
178
|
+
54
|
179
|
+
55
|
180
|
+
56
|
181
|
+
57</pre>
|
182
|
+
</td>
|
183
|
+
<td>
|
184
|
+
<pre class="code"><span class="info file"># File 'lib/sofa/mapping.rb', line 48</span>
|
185
|
+
|
186
|
+
def ==(obj)
|
187
|
+
if (klass = self.class) == obj.class
|
188
|
+
klass.mappings.inject(true) do |result, to_from|
|
189
|
+
to = to_from.last || to_from.first
|
190
|
+
result &&= (obj.send(to) == self.send(to))
|
191
|
+
end
|
192
|
+
else
|
193
|
+
super
|
194
|
+
end
|
195
|
+
end</pre>
|
196
|
+
</td>
|
197
|
+
</tr>
|
198
|
+
</table>
|
199
|
+
</div>
|
200
|
+
|
201
|
+
<div class="method_details ">
|
202
|
+
<p class="signature " id="attributes-instance_method">
|
203
|
+
|
204
|
+
- (<tt>Hash<Symbol, Object></tt>) <strong>attributes</strong>
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
</p><div class="docstring">
|
209
|
+
<div class="discussion">
|
210
|
+
<p>Returns hash of all the attributes, with attribute names as keys and attribute values as values.</p>
|
211
|
+
|
212
|
+
</div>
|
213
|
+
</div>
|
214
|
+
<div class="tags">
|
215
|
+
<h3>Returns:</h3>
|
216
|
+
<ul class="return">
|
217
|
+
|
218
|
+
<li>
|
219
|
+
|
220
|
+
<span class='type'>(<tt>Hash<Symbol, Object></tt>)</span>
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
—
|
226
|
+
Hash of all attributes
|
227
|
+
|
228
|
+
</li>
|
229
|
+
|
230
|
+
</ul>
|
231
|
+
|
232
|
+
<h3>See Also:</h3>
|
233
|
+
<ul class="see">
|
234
|
+
|
235
|
+
<li><a title="Sofa::Mapping::ClassMethods#maps" href="ClassMethods.html#maps-instance_method">Sofa::Mapping::ClassMethods#maps</a></li>
|
236
|
+
|
237
|
+
</ul>
|
238
|
+
|
239
|
+
</div><table class="source_code">
|
240
|
+
<tr>
|
241
|
+
<td>
|
242
|
+
<pre class="lines">
|
243
|
+
|
244
|
+
|
245
|
+
20
|
246
|
+
21
|
247
|
+
22
|
248
|
+
23
|
249
|
+
24
|
250
|
+
25
|
251
|
+
26
|
252
|
+
27</pre>
|
253
|
+
</td>
|
254
|
+
<td>
|
255
|
+
<pre class="code"><span class="info file"># File 'lib/sofa/mapping.rb', line 20</span>
|
256
|
+
|
257
|
+
def attributes
|
258
|
+
klass = self.class
|
259
|
+
klass.mappings.values.inject({}) do |attrs, to|
|
260
|
+
next unless to
|
261
|
+
attrs[to] = send(to)
|
262
|
+
attrs
|
263
|
+
end
|
264
|
+
end</pre>
|
265
|
+
</td>
|
266
|
+
</tr>
|
267
|
+
</table>
|
268
|
+
</div>
|
269
|
+
|
270
|
+
<div class="method_details ">
|
271
|
+
<p class="signature " id="update_with_mapping-instance_method">
|
272
|
+
|
273
|
+
- (<tt>Object</tt>) <strong>update_with_mapping</strong>(attributes = {})
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
</p><div class="docstring">
|
278
|
+
<div class="discussion">
|
279
|
+
<p>Updates all the attributes from the Hash.</p>
|
280
|
+
|
281
|
+
</div>
|
282
|
+
</div>
|
283
|
+
<div class="tags">
|
284
|
+
<h3>Parameters:</h3>
|
285
|
+
<ul class="param">
|
286
|
+
|
287
|
+
<li>
|
288
|
+
|
289
|
+
<span class='type'>(<tt>Hash<Symbol, Object></tt>)</span>
|
290
|
+
|
291
|
+
|
292
|
+
<span class='name'>attributes</span>
|
293
|
+
|
294
|
+
|
295
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
296
|
+
|
297
|
+
|
298
|
+
—
|
299
|
+
A hash with attribute names as keys and attribute values as values
|
300
|
+
|
301
|
+
</li>
|
302
|
+
|
303
|
+
</ul>
|
304
|
+
|
305
|
+
<h3>See Also:</h3>
|
306
|
+
<ul class="see">
|
307
|
+
|
308
|
+
<li><a title="Sofa::Mapping::ClassMethods#maps" href="ClassMethods.html#maps-instance_method">Sofa::Mapping::ClassMethods#maps</a></li>
|
309
|
+
|
310
|
+
</ul>
|
311
|
+
|
312
|
+
</div><table class="source_code">
|
313
|
+
<tr>
|
314
|
+
<td>
|
315
|
+
<pre class="lines">
|
316
|
+
|
317
|
+
|
318
|
+
33
|
319
|
+
34
|
320
|
+
35
|
321
|
+
36
|
322
|
+
37
|
323
|
+
38
|
324
|
+
39
|
325
|
+
40
|
326
|
+
41
|
327
|
+
42</pre>
|
328
|
+
</td>
|
329
|
+
<td>
|
330
|
+
<pre class="code"><span class="info file"># File 'lib/sofa/mapping.rb', line 33</span>
|
331
|
+
|
332
|
+
def update_with_mapping(attributes = {})
|
333
|
+
attributes.each do |key, value|
|
334
|
+
next unless (klass = self.class) and key.respond_to?(:to_sym) and to = klass.mappings[key.to_sym]
|
335
|
+
|
336
|
+
block = klass.mappings_procs[to]
|
337
|
+
value = block.call(value) if block
|
338
|
+
|
339
|
+
instance_variable_set("@#{to}", value)
|
340
|
+
end
|
341
|
+
end</pre>
|
342
|
+
</td>
|
343
|
+
</tr>
|
344
|
+
</table>
|
345
|
+
</div>
|
346
|
+
|
347
|
+
</div>
|
348
|
+
|
349
|
+
</div>
|
350
|
+
|
351
|
+
<div id="footer">
|
352
|
+
Generated on Sat Nov 21 20:13:52 2009 by
|
353
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool">yard</a>
|
354
|
+
0.4.0 (ruby-1.8.7).
|
355
|
+
</div>
|
356
|
+
|
357
|
+
</body>
|
358
|
+
</html>
|