acts_as_price 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -8
- data/README.rdoc +3 -1
- data/Rakefile +11 -16
- data/VERSION +1 -1
- data/acts_as_price.gemspec +56 -48
- data/lib/acts_as_price.rb +5 -1
- data/rdoc/ActiveRecord.html +154 -0
- data/rdoc/ActiveRecord/Acts.html +154 -0
- data/rdoc/ActiveRecord/Acts/Price.html +203 -0
- data/rdoc/ActiveRecord/Acts/Price/ClassMethods.html +251 -0
- data/rdoc/ActsAsPriceHelper.html +458 -0
- data/rdoc/README_rdoc.html +238 -0
- data/rdoc/created.rid +4 -1
- data/rdoc/images/brick.png +0 -0
- data/rdoc/images/brick_link.png +0 -0
- data/rdoc/images/bug.png +0 -0
- data/rdoc/images/bullet_black.png +0 -0
- data/rdoc/images/bullet_toggle_minus.png +0 -0
- data/rdoc/images/bullet_toggle_plus.png +0 -0
- data/rdoc/images/date.png +0 -0
- data/rdoc/images/find.png +0 -0
- data/rdoc/images/loadingAnimation.gif +0 -0
- data/rdoc/images/macFFBgHack.png +0 -0
- data/rdoc/images/package.png +0 -0
- data/rdoc/images/page_green.png +0 -0
- data/rdoc/images/page_white_text.png +0 -0
- data/rdoc/images/page_white_width.png +0 -0
- data/rdoc/images/plugin.png +0 -0
- data/rdoc/images/ruby.png +0 -0
- data/rdoc/images/tag_green.png +0 -0
- data/rdoc/images/wrench.png +0 -0
- data/rdoc/images/wrench_orange.png +0 -0
- data/rdoc/images/zoom.png +0 -0
- data/rdoc/index.html +74 -20
- data/rdoc/js/darkfish.js +116 -0
- data/rdoc/js/jquery.js +32 -0
- data/rdoc/js/quicksearch.js +114 -0
- data/rdoc/js/thickbox-compressed.js +10 -0
- data/rdoc/lib/acts_as_price_helper_rb.html +52 -0
- data/rdoc/lib/acts_as_price_rb.html +52 -0
- data/rdoc/rdoc.css +706 -0
- data/spec/advanced_tests/car_spec.rb +0 -19
- data/spec/advanced_tests/fueltype_spec.rb +0 -18
- data/spec/models/car.rb +3 -2
- data/spec/spec_helper.rb +23 -4
- metadata +93 -175
- data/Gemfile.lock +0 -166
@@ -0,0 +1,203 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Module: ActiveRecord::Acts::Price</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="../../rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="../../js/jquery.js" type="text/javascript"
|
13
|
+
charset="utf-8"></script>
|
14
|
+
<script src="../../js/thickbox-compressed.js" type="text/javascript"
|
15
|
+
charset="utf-8"></script>
|
16
|
+
<script src="../../js/quicksearch.js" type="text/javascript"
|
17
|
+
charset="utf-8"></script>
|
18
|
+
<script src="../../js/darkfish.js" type="text/javascript"
|
19
|
+
charset="utf-8"></script>
|
20
|
+
|
21
|
+
</head>
|
22
|
+
<body class="module">
|
23
|
+
|
24
|
+
<div id="metadata">
|
25
|
+
<div id="home-metadata">
|
26
|
+
<div id="home-section" class="section">
|
27
|
+
<h3 class="section-header">
|
28
|
+
<a href="../../index.html">Home</a>
|
29
|
+
<a href="../../index.html#classes">Classes</a>
|
30
|
+
<a href="../../index.html#methods">Methods</a>
|
31
|
+
</h3>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="file-metadata">
|
36
|
+
<div id="file-list-section" class="section">
|
37
|
+
<h3 class="section-header">In Files</h3>
|
38
|
+
<div class="section-body">
|
39
|
+
<ul>
|
40
|
+
|
41
|
+
<li><a href="../../lib/acts_as_price_rb.html?TB_iframe=true&height=550&width=785"
|
42
|
+
class="thickbox" title="lib/acts_as_price.rb">lib/acts_as_price.rb</a></li>
|
43
|
+
|
44
|
+
</ul>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div id="class-metadata">
|
52
|
+
|
53
|
+
<!-- Parent Class -->
|
54
|
+
|
55
|
+
|
56
|
+
<!-- Namespace Contents -->
|
57
|
+
|
58
|
+
<div id="namespace-list-section" class="section">
|
59
|
+
<h3 class="section-header">Namespace</h3>
|
60
|
+
<ul class="link-list">
|
61
|
+
|
62
|
+
<li><span class="type">MODULE</span> <a href="Price/ClassMethods.html">ActiveRecord::Acts::Price::ClassMethods</a></li>
|
63
|
+
|
64
|
+
</ul>
|
65
|
+
</div>
|
66
|
+
|
67
|
+
|
68
|
+
<!-- Method Quickref -->
|
69
|
+
|
70
|
+
<div id="method-list-section" class="section">
|
71
|
+
<h3 class="section-header">Methods</h3>
|
72
|
+
<ul class="link-list">
|
73
|
+
|
74
|
+
<li><a href="#method-c-included">::included</a></li>
|
75
|
+
|
76
|
+
</ul>
|
77
|
+
</div>
|
78
|
+
|
79
|
+
|
80
|
+
<!-- Included Modules -->
|
81
|
+
|
82
|
+
</div>
|
83
|
+
|
84
|
+
<div id="project-metadata">
|
85
|
+
|
86
|
+
|
87
|
+
<div id="fileindex-section" class="section project-section">
|
88
|
+
<h3 class="section-header">Files</h3>
|
89
|
+
<ul>
|
90
|
+
|
91
|
+
<li class="file"><a href="../../README_rdoc.html">README.rdoc</a></li>
|
92
|
+
|
93
|
+
</ul>
|
94
|
+
</div>
|
95
|
+
|
96
|
+
|
97
|
+
<div id="classindex-section" class="section project-section">
|
98
|
+
<h3 class="section-header">Class Index
|
99
|
+
<span class="search-toggle"><img src="../../images/find.png"
|
100
|
+
height="16" width="16" alt="[+]"
|
101
|
+
title="show/hide quicksearch" /></span></h3>
|
102
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
103
|
+
<fieldset>
|
104
|
+
<legend>Quicksearch</legend>
|
105
|
+
<input type="text" name="quicksearch" value=""
|
106
|
+
class="quicksearch-field" />
|
107
|
+
</fieldset>
|
108
|
+
</form>
|
109
|
+
|
110
|
+
<ul class="link-list">
|
111
|
+
|
112
|
+
<li><a href="../../ActiveRecord.html">ActiveRecord</a></li>
|
113
|
+
|
114
|
+
<li><a href="../../ActiveRecord/Acts.html">ActiveRecord::Acts</a></li>
|
115
|
+
|
116
|
+
<li><a href="../../ActiveRecord/Acts/Price.html">ActiveRecord::Acts::Price</a></li>
|
117
|
+
|
118
|
+
<li><a href="../../ActiveRecord/Acts/Price/ClassMethods.html">ActiveRecord::Acts::Price::ClassMethods</a></li>
|
119
|
+
|
120
|
+
<li><a href="../../ActsAsPriceHelper.html">ActsAsPriceHelper</a></li>
|
121
|
+
|
122
|
+
</ul>
|
123
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
124
|
+
</div>
|
125
|
+
|
126
|
+
|
127
|
+
</div>
|
128
|
+
</div>
|
129
|
+
|
130
|
+
<div id="documentation">
|
131
|
+
<h1 class="module">ActiveRecord::Acts::Price</h1>
|
132
|
+
|
133
|
+
<div id="description">
|
134
|
+
|
135
|
+
</div>
|
136
|
+
|
137
|
+
<!-- Constants -->
|
138
|
+
|
139
|
+
|
140
|
+
<!-- Attributes -->
|
141
|
+
|
142
|
+
|
143
|
+
<!-- Methods -->
|
144
|
+
|
145
|
+
<div id="public-class-method-details" class="method-section section">
|
146
|
+
<h3 class="section-header">Public Class Methods</h3>
|
147
|
+
|
148
|
+
|
149
|
+
<div id="included-method" class="method-detail ">
|
150
|
+
<a name="method-c-included"></a>
|
151
|
+
|
152
|
+
<div class="method-heading">
|
153
|
+
|
154
|
+
<span class="method-name">included</span><span
|
155
|
+
class="method-args">(base)</span>
|
156
|
+
<span class="method-click-advice">click to toggle source</span>
|
157
|
+
|
158
|
+
</div>
|
159
|
+
|
160
|
+
<div class="method-description">
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
<div class="method-source-code"
|
167
|
+
id="included-source">
|
168
|
+
<pre>
|
169
|
+
<span class="ruby-comment cmt"># File lib/acts_as_price.rb, line 5</span>
|
170
|
+
5: <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>)
|
171
|
+
6: <span class="ruby-identifier">base</span>.<span class="ruby-identifier">extend</span>(<span class="ruby-constant">ClassMethods</span>)
|
172
|
+
7: <span class="ruby-keyword kw">end</span></pre>
|
173
|
+
</div>
|
174
|
+
|
175
|
+
</div>
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
</div>
|
181
|
+
|
182
|
+
|
183
|
+
</div>
|
184
|
+
|
185
|
+
|
186
|
+
</div>
|
187
|
+
|
188
|
+
|
189
|
+
<div id="rdoc-debugging-section-dump" class="debugging-section">
|
190
|
+
|
191
|
+
<p>Disabled; run with --debug to generate this.</p>
|
192
|
+
|
193
|
+
</div>
|
194
|
+
|
195
|
+
<div id="validator-badges">
|
196
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
197
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
198
|
+
Rdoc Generator</a> 1.1.6</small>.</p>
|
199
|
+
</div>
|
200
|
+
|
201
|
+
</body>
|
202
|
+
</html>
|
203
|
+
|
@@ -0,0 +1,251 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Module: ActiveRecord::Acts::Price::ClassMethods</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="../../../rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="../../../js/jquery.js" type="text/javascript"
|
13
|
+
charset="utf-8"></script>
|
14
|
+
<script src="../../../js/thickbox-compressed.js" type="text/javascript"
|
15
|
+
charset="utf-8"></script>
|
16
|
+
<script src="../../../js/quicksearch.js" type="text/javascript"
|
17
|
+
charset="utf-8"></script>
|
18
|
+
<script src="../../../js/darkfish.js" type="text/javascript"
|
19
|
+
charset="utf-8"></script>
|
20
|
+
|
21
|
+
</head>
|
22
|
+
<body class="module">
|
23
|
+
|
24
|
+
<div id="metadata">
|
25
|
+
<div id="home-metadata">
|
26
|
+
<div id="home-section" class="section">
|
27
|
+
<h3 class="section-header">
|
28
|
+
<a href="../../../index.html">Home</a>
|
29
|
+
<a href="../../../index.html#classes">Classes</a>
|
30
|
+
<a href="../../../index.html#methods">Methods</a>
|
31
|
+
</h3>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="file-metadata">
|
36
|
+
<div id="file-list-section" class="section">
|
37
|
+
<h3 class="section-header">In Files</h3>
|
38
|
+
<div class="section-body">
|
39
|
+
<ul>
|
40
|
+
|
41
|
+
<li><a href="../../../lib/acts_as_price_rb.html?TB_iframe=true&height=550&width=785"
|
42
|
+
class="thickbox" title="lib/acts_as_price.rb">lib/acts_as_price.rb</a></li>
|
43
|
+
|
44
|
+
</ul>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div id="class-metadata">
|
52
|
+
|
53
|
+
<!-- Parent Class -->
|
54
|
+
|
55
|
+
|
56
|
+
<!-- Namespace Contents -->
|
57
|
+
|
58
|
+
|
59
|
+
<!-- Method Quickref -->
|
60
|
+
|
61
|
+
<div id="method-list-section" class="section">
|
62
|
+
<h3 class="section-header">Methods</h3>
|
63
|
+
<ul class="link-list">
|
64
|
+
|
65
|
+
<li><a href="#method-i-acts_as_price">#acts_as_price</a></li>
|
66
|
+
|
67
|
+
</ul>
|
68
|
+
</div>
|
69
|
+
|
70
|
+
|
71
|
+
<!-- Included Modules -->
|
72
|
+
|
73
|
+
</div>
|
74
|
+
|
75
|
+
<div id="project-metadata">
|
76
|
+
|
77
|
+
|
78
|
+
<div id="fileindex-section" class="section project-section">
|
79
|
+
<h3 class="section-header">Files</h3>
|
80
|
+
<ul>
|
81
|
+
|
82
|
+
<li class="file"><a href="../../../README_rdoc.html">README.rdoc</a></li>
|
83
|
+
|
84
|
+
</ul>
|
85
|
+
</div>
|
86
|
+
|
87
|
+
|
88
|
+
<div id="classindex-section" class="section project-section">
|
89
|
+
<h3 class="section-header">Class Index
|
90
|
+
<span class="search-toggle"><img src="../../../images/find.png"
|
91
|
+
height="16" width="16" alt="[+]"
|
92
|
+
title="show/hide quicksearch" /></span></h3>
|
93
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
94
|
+
<fieldset>
|
95
|
+
<legend>Quicksearch</legend>
|
96
|
+
<input type="text" name="quicksearch" value=""
|
97
|
+
class="quicksearch-field" />
|
98
|
+
</fieldset>
|
99
|
+
</form>
|
100
|
+
|
101
|
+
<ul class="link-list">
|
102
|
+
|
103
|
+
<li><a href="../../../ActiveRecord.html">ActiveRecord</a></li>
|
104
|
+
|
105
|
+
<li><a href="../../../ActiveRecord/Acts.html">ActiveRecord::Acts</a></li>
|
106
|
+
|
107
|
+
<li><a href="../../../ActiveRecord/Acts/Price.html">ActiveRecord::Acts::Price</a></li>
|
108
|
+
|
109
|
+
<li><a href="../../../ActiveRecord/Acts/Price/ClassMethods.html">ActiveRecord::Acts::Price::ClassMethods</a></li>
|
110
|
+
|
111
|
+
<li><a href="../../../ActsAsPriceHelper.html">ActsAsPriceHelper</a></li>
|
112
|
+
|
113
|
+
</ul>
|
114
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
115
|
+
</div>
|
116
|
+
|
117
|
+
|
118
|
+
</div>
|
119
|
+
</div>
|
120
|
+
|
121
|
+
<div id="documentation">
|
122
|
+
<h1 class="module">ActiveRecord::Acts::Price::ClassMethods</h1>
|
123
|
+
|
124
|
+
<div id="description">
|
125
|
+
|
126
|
+
</div>
|
127
|
+
|
128
|
+
<!-- Constants -->
|
129
|
+
|
130
|
+
|
131
|
+
<!-- Attributes -->
|
132
|
+
|
133
|
+
|
134
|
+
<!-- Methods -->
|
135
|
+
|
136
|
+
<div id="public-instance-method-details" class="method-section section">
|
137
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
138
|
+
|
139
|
+
|
140
|
+
<div id="acts-as-price-method" class="method-detail ">
|
141
|
+
<a name="method-i-acts_as_price"></a>
|
142
|
+
|
143
|
+
<div class="method-heading">
|
144
|
+
|
145
|
+
<span class="method-name">acts_as_price</span><span
|
146
|
+
class="method-args">(column_name, options = {})</span>
|
147
|
+
<span class="method-click-advice">click to toggle source</span>
|
148
|
+
|
149
|
+
</div>
|
150
|
+
|
151
|
+
<div class="method-description">
|
152
|
+
|
153
|
+
<p>
|
154
|
+
Specify the column_name that needs to act as price
|
155
|
+
</p>
|
156
|
+
<p>
|
157
|
+
Valid options:
|
158
|
+
</p>
|
159
|
+
<ul>
|
160
|
+
<li><p>
|
161
|
+
:validates => true (performs validates_presence_of and
|
162
|
+
validates_numericality_of)
|
163
|
+
</p>
|
164
|
+
</li>
|
165
|
+
<li><p>
|
166
|
+
:comma_seperated => true (set and get the price as a comma-seperated value)
|
167
|
+
</p>
|
168
|
+
</li>
|
169
|
+
</ul>
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
<div class="method-source-code"
|
174
|
+
id="acts-as-price-source">
|
175
|
+
<pre>
|
176
|
+
<span class="ruby-comment cmt"># File lib/acts_as_price.rb, line 15</span>
|
177
|
+
15: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">acts_as_price</span> <span class="ruby-identifier">column_name</span>, <span class="ruby-identifier">options</span> = {}
|
178
|
+
16: <span class="ruby-identifier">validates</span> <span class="ruby-identifier">column_name</span>, <span class="ruby-value">:presence</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>, <span class="ruby-value">:numericality</span> =<span class="ruby-operator">></span> {<span class="ruby-value">:greater_than</span> =<span class="ruby-operator">></span> <span class="ruby-value">0</span>} <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:validates</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
|
179
|
+
17: <span class="ruby-identifier">currency</span>, <span class="ruby-identifier">comma</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:currency</span>], <span class="ruby-identifier">options</span>[<span class="ruby-value">:comma_seperated</span>]
|
180
|
+
18:
|
181
|
+
19: <span class="ruby-comment cmt">#setters</span>
|
182
|
+
20: <span class="ruby-identifier">define_method</span>(<span class="ruby-node">"#{column_name}="</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">val</span><span class="ruby-operator">|</span>
|
183
|
+
21: <span class="ruby-keyword kw">super</span>(((<span class="ruby-identifier">val</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">","</span>, <span class="ruby-value str">"."</span>).<span class="ruby-identifier">to_f</span> * <span class="ruby-value">100</span>) <span class="ruby-operator">+</span> <span class="ruby-value">0.5</span>).<span class="ruby-identifier">to_s</span>)
|
184
|
+
22: <span class="ruby-keyword kw">end</span>
|
185
|
+
23: <span class="ruby-identifier">alias_method</span>(<span class="ruby-value str">"price="</span>, <span class="ruby-node">"#{column_name}="</span>)
|
186
|
+
24:
|
187
|
+
25: <span class="ruby-identifier">define_method</span>(<span class="ruby-value str">"price_in_cents="</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">val</span><span class="ruby-operator">|</span>
|
188
|
+
26: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-value str">"price="</span>, <span class="ruby-identifier">val</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-value">100</span>)
|
189
|
+
27: <span class="ruby-keyword kw">end</span>
|
190
|
+
28: <span class="ruby-identifier">alias_method</span> <span class="ruby-node">"#{column_name}_in_cents="</span>, <span class="ruby-value str">"price_in_cents="</span>
|
191
|
+
29:
|
192
|
+
30: <span class="ruby-comment cmt">#getters</span>
|
193
|
+
31: <span class="ruby-identifier">define_method</span>(<span class="ruby-identifier">column_name</span>) <span class="ruby-keyword kw">do</span>
|
194
|
+
32: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">super</span>().<span class="ruby-identifier">blank?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-keyword kw">super</span>() <span class="ruby-operator">==</span> <span class="ruby-value">0.0</span>
|
195
|
+
33: <span class="ruby-value str">""</span>
|
196
|
+
34: <span class="ruby-keyword kw">else</span>
|
197
|
+
35: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">comma</span>
|
198
|
+
36: <span class="ruby-identifier">return_val</span> = <span class="ruby-identifier">sprintf</span>(<span class="ruby-value str">"%.2f"</span>, <span class="ruby-keyword kw">super</span>().<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-value">100</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">"."</span>, <span class="ruby-value str">","</span>)
|
199
|
+
37: <span class="ruby-keyword kw">else</span>
|
200
|
+
38: <span class="ruby-identifier">return_val</span> = <span class="ruby-identifier">sprintf</span>(<span class="ruby-value str">"%.2f"</span>, <span class="ruby-keyword kw">super</span>().<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-value">100</span>)
|
201
|
+
39: <span class="ruby-keyword kw">end</span>
|
202
|
+
40: <span class="ruby-identifier">return_val</span> = <span class="ruby-identifier">currency</span> <span class="ruby-operator">?</span> <span class="ruby-node">"#{currency}. #{return_val}"</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">return_val</span>
|
203
|
+
41: <span class="ruby-identifier">return_val</span>
|
204
|
+
42: <span class="ruby-keyword kw">end</span>
|
205
|
+
43: <span class="ruby-keyword kw">end</span>
|
206
|
+
44: <span class="ruby-identifier">alias_method</span> <span class="ruby-value str">"price"</span>, <span class="ruby-identifier">column_name</span>
|
207
|
+
45:
|
208
|
+
46: <span class="ruby-identifier">define_method</span>(<span class="ruby-value str">"price_in_cents"</span>) <span class="ruby-keyword kw">do</span>
|
209
|
+
47: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">currency</span>
|
210
|
+
48: ((<span class="ruby-identifier">send</span> <span class="ruby-identifier">column_name</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-node">"#{currency}. "</span>, <span class="ruby-value str">""</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">","</span>, <span class="ruby-value str">"."</span>).<span class="ruby-identifier">to_f</span> * <span class="ruby-value">100</span>).<span class="ruby-identifier">round</span>
|
211
|
+
49: <span class="ruby-keyword kw">else</span>
|
212
|
+
50: ((<span class="ruby-identifier">send</span> <span class="ruby-identifier">column_name</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">","</span>, <span class="ruby-value str">"."</span>).<span class="ruby-identifier">to_f</span> * <span class="ruby-value">100</span>).<span class="ruby-identifier">round</span>
|
213
|
+
51: <span class="ruby-keyword kw">end</span>
|
214
|
+
52: <span class="ruby-keyword kw">end</span>
|
215
|
+
53: <span class="ruby-identifier">alias_method</span> <span class="ruby-node">"#{column_name}_in_cents"</span>, <span class="ruby-value str">"price_in_cents"</span>
|
216
|
+
54:
|
217
|
+
55: <span class="ruby-identifier">define_method</span>(<span class="ruby-value str">"currency"</span>) <span class="ruby-keyword kw">do</span>
|
218
|
+
56: <span class="ruby-identifier">currency</span>
|
219
|
+
57: <span class="ruby-keyword kw">end</span>
|
220
|
+
58: <span class="ruby-keyword kw">end</span></pre>
|
221
|
+
</div>
|
222
|
+
|
223
|
+
</div>
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
</div>
|
229
|
+
|
230
|
+
|
231
|
+
</div>
|
232
|
+
|
233
|
+
|
234
|
+
</div>
|
235
|
+
|
236
|
+
|
237
|
+
<div id="rdoc-debugging-section-dump" class="debugging-section">
|
238
|
+
|
239
|
+
<p>Disabled; run with --debug to generate this.</p>
|
240
|
+
|
241
|
+
</div>
|
242
|
+
|
243
|
+
<div id="validator-badges">
|
244
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
245
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
246
|
+
Rdoc Generator</a> 1.1.6</small>.</p>
|
247
|
+
</div>
|
248
|
+
|
249
|
+
</body>
|
250
|
+
</html>
|
251
|
+
|