acts_as_eav_model 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -0
- data/CHANGELOG +3 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +92 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +117 -0
- data/Rakefile +46 -0
- data/SPECDOC +23 -0
- data/TODO +0 -0
- data/VERSION +1 -0
- data/doc/classes/ActiveRecord/Acts/EavModel.html +213 -0
- data/doc/classes/ActiveRecord/Acts/EavModel/ClassMethods.html +343 -0
- data/doc/classes/ActiveRecord/Acts/EavModel/InstanceMethods.html +474 -0
- data/doc/classes/ActiveRecord/Acts/EavModel/InstanceMethods/ClassMethods.html +192 -0
- data/doc/classes/ActiveRecord/Base.html +170 -0
- data/doc/created.rid +1 -0
- data/doc/files/CHANGELOG.html +113 -0
- data/doc/files/MIT-LICENSE.html +129 -0
- data/doc/files/README_rdoc.html +248 -0
- data/doc/files/SPECDOC.html +170 -0
- data/doc/files/lib/acts_as_eav_model_rb.html +101 -0
- data/doc/fr_class_index.html +31 -0
- data/doc/fr_file_index.html +31 -0
- data/doc/fr_method_index.html +40 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/init.rb +1 -0
- data/install.rb +1 -0
- data/lib/acts_as_eav_model.rb +542 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/document.rb +7 -0
- data/spec/dummy/app/models/person.rb +13 -0
- data/spec/dummy/app/models/person_contact_info.rb +2 -0
- data/spec/dummy/app/models/post.rb +4 -0
- data/spec/dummy/app/models/post_attribute.rb +2 -0
- data/spec/dummy/app/models/preference.rb +5 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +51 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +175 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/fixtures/people.yml +4 -0
- data/spec/fixtures/person_contact_infos.yml +10 -0
- data/spec/fixtures/post_attributes.yml +15 -0
- data/spec/fixtures/posts.yml +9 -0
- data/spec/fixtures/preferences.yml +10 -0
- data/spec/models/eav_model_with_no_arguments_spec.rb +82 -0
- data/spec/models/eav_model_with_options_spec.rb +37 -0
- data/spec/models/eav_validation_spec.rb +11 -0
- data/spec/schema.rb +50 -0
- data/spec/spec_helper.rb +38 -0
- data/uninstall.rb +1 -0
- metadata +213 -0
@@ -0,0 +1,129 @@
|
|
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>File: MIT-LICENSE</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="fileHeader">
|
50
|
+
<h1>MIT-LICENSE</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>MIT-LICENSE
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Thu Dec 18 13:10:57 +1300 2008</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<p>
|
73
|
+
Copyright (c) 2008 Marcus Wyatt
|
74
|
+
</p>
|
75
|
+
<p>
|
76
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
77
|
+
copy of this software and associated documentation files (the
|
78
|
+
"Software"), to deal in the Software without restriction,
|
79
|
+
including without limitation the rights to use, copy, modify, merge,
|
80
|
+
publish, distribute, sublicense, and/or sell copies of the Software, and to
|
81
|
+
permit persons to whom the Software is furnished to do so, subject to the
|
82
|
+
following conditions:
|
83
|
+
</p>
|
84
|
+
<p>
|
85
|
+
The above copyright notice and this permission notice shall be included in
|
86
|
+
all copies or substantial portions of the Software.
|
87
|
+
</p>
|
88
|
+
<p>
|
89
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
90
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
91
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
92
|
+
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
93
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
94
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
95
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
96
|
+
</p>
|
97
|
+
|
98
|
+
</div>
|
99
|
+
|
100
|
+
|
101
|
+
</div>
|
102
|
+
|
103
|
+
|
104
|
+
</div>
|
105
|
+
|
106
|
+
|
107
|
+
<!-- if includes -->
|
108
|
+
|
109
|
+
<div id="section">
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
<!-- if method_list -->
|
119
|
+
|
120
|
+
|
121
|
+
</div>
|
122
|
+
|
123
|
+
|
124
|
+
<div id="validator-badges">
|
125
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
126
|
+
</div>
|
127
|
+
|
128
|
+
</body>
|
129
|
+
</html>
|
@@ -0,0 +1,248 @@
|
|
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>File: README.rdoc</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="fileHeader">
|
50
|
+
<h1>README.rdoc</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>README.rdoc
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Thu Dec 18 11:13:37 +1300 2008</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<p>
|
73
|
+
ActsAsEavModel
|
74
|
+
</p>
|
75
|
+
<h6>========</h6>
|
76
|
+
<p>
|
77
|
+
ActsAsEavModel allow for the Entity-attribute-value model (EAV), also known
|
78
|
+
as object-attribute-value model and open schema on any of your ActiveRecord
|
79
|
+
models.
|
80
|
+
</p>
|
81
|
+
<h1>What is Entity-attribute-value model?</h1>
|
82
|
+
<p>
|
83
|
+
Entity-attribute-value model (EAV) is a data model that is used in
|
84
|
+
circumstances where the number of attributes (properties, parameters) that
|
85
|
+
can be used to describe a thing (an "entity" or
|
86
|
+
"object") is potentially very vast, but the number that will
|
87
|
+
actually apply to a given entity is relatively modest.
|
88
|
+
</p>
|
89
|
+
<h1>Typical Problem</h1>
|
90
|
+
<p>
|
91
|
+
A good example of this is where you need to store lots (possible hundreds)
|
92
|
+
of optional attributes on an object. My typical reference example is when
|
93
|
+
you have a User object. You want to store the user‘s preferences
|
94
|
+
between sessions. Every search, sort, etc in your application you want to
|
95
|
+
keep track of so when the user visits that section of the application again
|
96
|
+
you can simply restore the display to how it was.
|
97
|
+
</p>
|
98
|
+
<p>
|
99
|
+
So your controller might have:
|
100
|
+
</p>
|
101
|
+
<pre>
|
102
|
+
Project.find :all, :conditions => current_user.project_search,
|
103
|
+
:order => current_user.project_order
|
104
|
+
</pre>
|
105
|
+
<p>
|
106
|
+
But there could be hundreds of these little attributes that you really
|
107
|
+
don‘t want to store directly on the user object. It would make your
|
108
|
+
table have too many columns so it would be too much of a pain to deal with.
|
109
|
+
Also there might be performance problems. So instead you might do something
|
110
|
+
like this:
|
111
|
+
</p>
|
112
|
+
<pre>
|
113
|
+
class User < ActiveRecord::Base
|
114
|
+
has_many :preferences
|
115
|
+
end
|
116
|
+
|
117
|
+
class Preferences < ActiveRecord::Base
|
118
|
+
belongs_to :user
|
119
|
+
end
|
120
|
+
</pre>
|
121
|
+
<p>
|
122
|
+
Now simply give the Preference model a "name" and
|
123
|
+
"value" column and you are set.…. except this is now too
|
124
|
+
complicated. To retrieve a attribute you will need to do something like:
|
125
|
+
</p>
|
126
|
+
<pre>
|
127
|
+
Project.find :all,
|
128
|
+
:conditions => current_user.preferences.find_by_name('project_search').value,
|
129
|
+
:order => current_user.preferences.find_by_name('project_order').value
|
130
|
+
</pre>
|
131
|
+
<p>
|
132
|
+
Sure you could fix this through a few methods on your model. But what about
|
133
|
+
saving?
|
134
|
+
</p>
|
135
|
+
<pre>
|
136
|
+
current_user.preferences.create :name => 'project_search',
|
137
|
+
:value => "lastname LIKE 'jones%'"
|
138
|
+
current_user.preferences.create :name => 'project_order',
|
139
|
+
:value => "name"
|
140
|
+
</pre>
|
141
|
+
<p>
|
142
|
+
Again this seems to much. Again we could add some methods to our model to
|
143
|
+
make this simpler but do we want to do this on every model. NO! So instead
|
144
|
+
we use this plugin which does everything for us.
|
145
|
+
</p>
|
146
|
+
<h1>Capabilities</h1>
|
147
|
+
<p>
|
148
|
+
The ActsAsEavModel plugin is capable of modeling this problem in a
|
149
|
+
intuitive way. Instead of having to deal with a related model you treat all
|
150
|
+
attributes (both on the model and related) as if they are all on the model.
|
151
|
+
The plugin will try to save all attributes to the model (normal
|
152
|
+
ActiveRecord behavior) but if there is no column for an attribute it will
|
153
|
+
try to save it to a related model whose purpose is to store these many
|
154
|
+
sparsely populated attributes.
|
155
|
+
</p>
|
156
|
+
<p>
|
157
|
+
The main design goals are:
|
158
|
+
</p>
|
159
|
+
<ul>
|
160
|
+
<li>Have the eav attributes feel like normal attributes. Simple gets and sets
|
161
|
+
will add and remove records from the related model.
|
162
|
+
|
163
|
+
</li>
|
164
|
+
<li>Allow for more than one related model. So for example on my User model I
|
165
|
+
might have some eav behavior going into a contact_info table while others
|
166
|
+
are going in a user_preferences table.
|
167
|
+
|
168
|
+
</li>
|
169
|
+
<li>Allow a model to determine what a valid eav attribute is for a given
|
170
|
+
related model so our model still can generate a NoMethodError.
|
171
|
+
|
172
|
+
</li>
|
173
|
+
</ul>
|
174
|
+
<p>
|
175
|
+
Example
|
176
|
+
</p>
|
177
|
+
<h6>=</h6>
|
178
|
+
<p>
|
179
|
+
Will make the current class have eav behaviour.
|
180
|
+
</p>
|
181
|
+
<pre>
|
182
|
+
class Post < ActiveRecord::Base
|
183
|
+
has_eav_behavior
|
184
|
+
end
|
185
|
+
post = Post.find_by_title 'hello world'
|
186
|
+
puts "My post intro is: #{post.intro}"
|
187
|
+
post.teaser = 'An awesome introduction to the blog'
|
188
|
+
post.save
|
189
|
+
</pre>
|
190
|
+
<p>
|
191
|
+
The above example should work even though "intro" and
|
192
|
+
"teaser" are not attributes on the Post model.
|
193
|
+
</p>
|
194
|
+
<h1>Installation</h1>
|
195
|
+
<pre>
|
196
|
+
./script/plugin install acts_as_eav_model
|
197
|
+
</pre>
|
198
|
+
<h1>RUNNING UNIT TESTS</h1>
|
199
|
+
<h2>Creating the test database</h2>
|
200
|
+
<p>
|
201
|
+
The test databases will be created from the info specified in
|
202
|
+
test/database.yml. Either change that file to match your database or change
|
203
|
+
your database to match that file.
|
204
|
+
</p>
|
205
|
+
<h2>Running with Rake</h2>
|
206
|
+
<p>
|
207
|
+
The easiest way to run the unit tests is through Rake. By default sqlite3
|
208
|
+
will be the database run. Just change your env variable DB to be the
|
209
|
+
database adaptor (specified in database.yml) that you want to use. The
|
210
|
+
database and permissions must already be setup but the tables will be
|
211
|
+
created for you from schema.rb.
|
212
|
+
</p>
|
213
|
+
<p>
|
214
|
+
Copyright (c) 2008 Marcus Wyatt, released under the MIT license
|
215
|
+
</p>
|
216
|
+
|
217
|
+
</div>
|
218
|
+
|
219
|
+
|
220
|
+
</div>
|
221
|
+
|
222
|
+
|
223
|
+
</div>
|
224
|
+
|
225
|
+
|
226
|
+
<!-- if includes -->
|
227
|
+
|
228
|
+
<div id="section">
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
<!-- if method_list -->
|
238
|
+
|
239
|
+
|
240
|
+
</div>
|
241
|
+
|
242
|
+
|
243
|
+
<div id="validator-badges">
|
244
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
245
|
+
</div>
|
246
|
+
|
247
|
+
</body>
|
248
|
+
</html>
|
@@ -0,0 +1,170 @@
|
|
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>File: SPECDOC</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="fileHeader">
|
50
|
+
<h1>SPECDOC</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>SPECDOC
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Thu Dec 18 13:47:02 +1300 2008</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<p>
|
73
|
+
ActiveRecord Model annotated with ‘has_eav_behavior’ with no
|
74
|
+
options in declaration
|
75
|
+
</p>
|
76
|
+
<ul>
|
77
|
+
<li>should have many attributes
|
78
|
+
|
79
|
+
</li>
|
80
|
+
<li>should create new attribute on save
|
81
|
+
|
82
|
+
</li>
|
83
|
+
<li>should delete attribute
|
84
|
+
|
85
|
+
</li>
|
86
|
+
<li>should write eav attributes to attributes table
|
87
|
+
|
88
|
+
</li>
|
89
|
+
<li>should return nil when attribute does not exist
|
90
|
+
|
91
|
+
</li>
|
92
|
+
<li>should use method missing to make attribute seem as native property
|
93
|
+
|
94
|
+
</li>
|
95
|
+
<li>should read attributes using subscript notation
|
96
|
+
|
97
|
+
</li>
|
98
|
+
<li>should read the attribute when invoking ‘read_attribute‘
|
99
|
+
|
100
|
+
</li>
|
101
|
+
</ul>
|
102
|
+
<p>
|
103
|
+
ActiveRecord Model annotated with ‘has_eav_behavior’ with
|
104
|
+
options in declaration
|
105
|
+
</p>
|
106
|
+
<ul>
|
107
|
+
<li>should be ‘has_many’ association on both sides
|
108
|
+
|
109
|
+
</li>
|
110
|
+
<li>should only allow restricted fields when specified (:fields => %w(phone
|
111
|
+
aim icq))
|
112
|
+
|
113
|
+
</li>
|
114
|
+
<li>should raise ‘NoMethodError’ when attribute not in
|
115
|
+
‘eav_attributes’ method array
|
116
|
+
|
117
|
+
</li>
|
118
|
+
<li>should raise ‘NoMethodError’ when attribute does not satisfy
|
119
|
+
‘is_eav_attribute?’ method
|
120
|
+
|
121
|
+
</li>
|
122
|
+
</ul>
|
123
|
+
<p>
|
124
|
+
Validations on ActiveRecord Model annotated with
|
125
|
+
‘has_eav_behavior‘
|
126
|
+
</p>
|
127
|
+
<ul>
|
128
|
+
<li>should execute as normal (validates_presence_of)
|
129
|
+
|
130
|
+
</li>
|
131
|
+
</ul>
|
132
|
+
<p>
|
133
|
+
Finished in 0.239663 seconds
|
134
|
+
</p>
|
135
|
+
<p>
|
136
|
+
13 examples, 0 failures
|
137
|
+
</p>
|
138
|
+
|
139
|
+
</div>
|
140
|
+
|
141
|
+
|
142
|
+
</div>
|
143
|
+
|
144
|
+
|
145
|
+
</div>
|
146
|
+
|
147
|
+
|
148
|
+
<!-- if includes -->
|
149
|
+
|
150
|
+
<div id="section">
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
<!-- if method_list -->
|
160
|
+
|
161
|
+
|
162
|
+
</div>
|
163
|
+
|
164
|
+
|
165
|
+
<div id="validator-badges">
|
166
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
167
|
+
</div>
|
168
|
+
|
169
|
+
</body>
|
170
|
+
</html>
|