has_eav 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/has_eav.gemspec +5 -1
- data/lib/has_eav.rb +14 -5
- data/test/app/models/special_post.rb +2 -0
- data/test/db/migrate/20101210125857_add_type_to_post.rb +9 -0
- data/test/test_has_eav.rb +6 -0
- metadata +7 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/has_eav.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{has_eav}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Hartog C. de Mik"]
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
"test/app/models/post_attribute.rb",
|
32
32
|
"test/app/models/product.rb",
|
33
33
|
"test/app/models/product_attribute.rb",
|
34
|
+
"test/app/models/special_post.rb",
|
34
35
|
"test/config.ru",
|
35
36
|
"test/config/application.rb",
|
36
37
|
"test/config/boot.rb",
|
@@ -50,6 +51,7 @@ Gem::Specification.new do |s|
|
|
50
51
|
"test/db/migrate/20101210100309_create_post_attributes.rb",
|
51
52
|
"test/db/migrate/20101210102322_create_products.rb",
|
52
53
|
"test/db/migrate/20101210102347_create_product_attributes.rb",
|
54
|
+
"test/db/migrate/20101210125857_add_type_to_post.rb",
|
53
55
|
"test/helper.rb",
|
54
56
|
"test/log/development.log",
|
55
57
|
"test/script/rails",
|
@@ -73,6 +75,7 @@ Gem::Specification.new do |s|
|
|
73
75
|
"test/app/models/post_attribute.rb",
|
74
76
|
"test/app/models/product.rb",
|
75
77
|
"test/app/models/product_attribute.rb",
|
78
|
+
"test/app/models/special_post.rb",
|
76
79
|
"test/config/application.rb",
|
77
80
|
"test/config/boot.rb",
|
78
81
|
"test/config/environment.rb",
|
@@ -89,6 +92,7 @@ Gem::Specification.new do |s|
|
|
89
92
|
"test/db/migrate/20101210100309_create_post_attributes.rb",
|
90
93
|
"test/db/migrate/20101210102322_create_products.rb",
|
91
94
|
"test/db/migrate/20101210102347_create_product_attributes.rb",
|
95
|
+
"test/db/migrate/20101210125857_add_type_to_post.rb",
|
92
96
|
"test/helper.rb",
|
93
97
|
"test/test/unit/post_attribute_test.rb",
|
94
98
|
"test/test/unit/post_test.rb",
|
data/lib/has_eav.rb
CHANGED
@@ -56,14 +56,18 @@ module ActiveRecord
|
|
56
56
|
self.class_eav_attributes[name] = type
|
57
57
|
end
|
58
58
|
|
59
|
-
# class accessor
|
59
|
+
# class accessor - when the superclass != AR::Base asume we are in STI
|
60
|
+
# mode
|
60
61
|
def class_eav_attributes # :nodoc:
|
61
|
-
|
62
|
+
superclass != ActiveRecord::Base ?
|
63
|
+
superclass.class_eav_attributes :
|
64
|
+
@eav_attributes
|
62
65
|
end
|
63
66
|
|
64
|
-
# class accessor
|
67
|
+
# class accessor - when the superclass != AR::Base asume we are in STI
|
68
|
+
# mode
|
65
69
|
def eav_class # :nodoc:
|
66
|
-
@eav_class
|
70
|
+
superclass != ActiveRecord::Base ? superclass.eav_class : @eav_class
|
67
71
|
end
|
68
72
|
end # /ClassMethods
|
69
73
|
|
@@ -188,7 +192,12 @@ module ActiveRecord
|
|
188
192
|
|
189
193
|
# get the key to my <3
|
190
194
|
def self_key # :nodoc:
|
191
|
-
|
195
|
+
klass = self.class
|
196
|
+
if klass.superclass != ActiveRecord::Base
|
197
|
+
klass = klass.superclass
|
198
|
+
end
|
199
|
+
|
200
|
+
"#{klass.name.underscore}_id".to_sym
|
192
201
|
end
|
193
202
|
|
194
203
|
# cast an eav value to it's desired class
|
data/test/test_has_eav.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_eav
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Hartog C. de Mik
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- test/app/models/post_attribute.rb
|
149
149
|
- test/app/models/product.rb
|
150
150
|
- test/app/models/product_attribute.rb
|
151
|
+
- test/app/models/special_post.rb
|
151
152
|
- test/config.ru
|
152
153
|
- test/config/application.rb
|
153
154
|
- test/config/boot.rb
|
@@ -167,6 +168,7 @@ files:
|
|
167
168
|
- test/db/migrate/20101210100309_create_post_attributes.rb
|
168
169
|
- test/db/migrate/20101210102322_create_products.rb
|
169
170
|
- test/db/migrate/20101210102347_create_product_attributes.rb
|
171
|
+
- test/db/migrate/20101210125857_add_type_to_post.rb
|
170
172
|
- test/helper.rb
|
171
173
|
- test/log/development.log
|
172
174
|
- test/script/rails
|
@@ -218,6 +220,7 @@ test_files:
|
|
218
220
|
- test/app/models/post_attribute.rb
|
219
221
|
- test/app/models/product.rb
|
220
222
|
- test/app/models/product_attribute.rb
|
223
|
+
- test/app/models/special_post.rb
|
221
224
|
- test/config/application.rb
|
222
225
|
- test/config/boot.rb
|
223
226
|
- test/config/environment.rb
|
@@ -234,6 +237,7 @@ test_files:
|
|
234
237
|
- test/db/migrate/20101210100309_create_post_attributes.rb
|
235
238
|
- test/db/migrate/20101210102322_create_products.rb
|
236
239
|
- test/db/migrate/20101210102347_create_product_attributes.rb
|
240
|
+
- test/db/migrate/20101210125857_add_type_to_post.rb
|
237
241
|
- test/helper.rb
|
238
242
|
- test/test/unit/post_attribute_test.rb
|
239
243
|
- test/test/unit/post_test.rb
|