CITIEsForRAILS 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CITIEsForRAILS.gemspec +2 -2
- data/Rakefile +1 -1
- data/lib/citiesforrails/acts_as_cities.rb +14 -5
- metadata +3 -3
data/CITIEsForRAILS.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{CITIEsForRAILS}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.6"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Laurent Buffat & Pierre-Emmanuel JOUVE"]
|
9
|
-
s.date = %q{2011-
|
9
|
+
s.date = %q{2011-05-18}
|
10
10
|
s.description = %q{CITIEsForRAILS (Class Inheritance & Table Inheritance Embeddings For RAILS) is a solution that extends Single/Multiple/Class Table Inheritance. This solution is based on classical Ruby class inheritance, single table inheritance as well as DB views.
|
11
11
|
|
12
12
|
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('CITIEsForRAILS', '0.0.
|
5
|
+
Echoe.new('CITIEsForRAILS', '0.0.6') do |p|
|
6
6
|
p.description = "CITIEsForRAILS (Class Inheritance & Table Inheritance Embeddings For RAILS) is a solution that extends Single/Multiple/Class Table Inheritance. This solution is based on classical Ruby class inheritance, single table inheritance as well as DB views.
|
7
7
|
|
8
8
|
|
@@ -145,7 +145,7 @@ module Cities
|
|
145
145
|
|
146
146
|
module InstanceMethods1
|
147
147
|
|
148
|
-
def save
|
148
|
+
def save #this gonna be used for the lowest level of hierarchy
|
149
149
|
|
150
150
|
|
151
151
|
attributes_for_super = self.attributes.select{|key,value| self.class.superclass.column_names.include?(key) } #get the attributes of the class of the instance that also belong to its superclass
|
@@ -153,6 +153,7 @@ module Cities
|
|
153
153
|
# these pieces of information should be stored in the table associated to the class of the instance
|
154
154
|
herited = self.class.superclass.new(attributes_for_super) #create a new instance of the superclass of the considered instance (self)
|
155
155
|
if(!new_record?)
|
156
|
+
puts "S1"
|
156
157
|
herited.swap_new_record
|
157
158
|
herited.id = self.id
|
158
159
|
end
|
@@ -173,6 +174,7 @@ module Cities
|
|
173
174
|
part_of.id = herited.id
|
174
175
|
|
175
176
|
if(!new_record?)
|
177
|
+
puts "S2"
|
176
178
|
part_of.swap_new_record
|
177
179
|
end
|
178
180
|
|
@@ -184,7 +186,11 @@ module Cities
|
|
184
186
|
|
185
187
|
|
186
188
|
self.id = herited.id
|
187
|
-
|
189
|
+
|
190
|
+
if(new_record?)
|
191
|
+
herited.swap_new_record;#this is very important for multi saving without reloading, if it was not there it would imply several savings in DB....
|
192
|
+
end
|
193
|
+
|
188
194
|
sql = "UPDATE #{self.class.mother_class.table_name} SET #{self.class.inheritance_column} = '#{self.class.to_s}' WHERE id = #{self.id}"
|
189
195
|
if RAILS_ENV == 'development'
|
190
196
|
puts "SQL : #{sql}"
|
@@ -195,7 +201,7 @@ module Cities
|
|
195
201
|
|
196
202
|
|
197
203
|
|
198
|
-
def saveBis
|
204
|
+
def saveBis #this gonna be used for the intermediate level of hierarchy
|
199
205
|
|
200
206
|
|
201
207
|
attributes_for_super = self.attributes.select{|key,value| self.class.superclass.column_names.include?(key) } #get the attributes of the class of the instance that also belong to its superclass
|
@@ -203,6 +209,7 @@ module Cities
|
|
203
209
|
# these pieces of information should be stored in the table associated to the class of the instance
|
204
210
|
herited = self.class.superclass.new(attributes_for_super) #create a new instance of the superclass of the considered instance (self)
|
205
211
|
if(!new_record?)
|
212
|
+
puts "S3"
|
206
213
|
herited.swap_new_record
|
207
214
|
herited.id = self.id
|
208
215
|
end
|
@@ -224,6 +231,7 @@ module Cities
|
|
224
231
|
part_of.id = herited.id
|
225
232
|
|
226
233
|
if(!new_record?)
|
234
|
+
puts "S4"
|
227
235
|
part_of.swap_new_record
|
228
236
|
end
|
229
237
|
|
@@ -273,9 +281,10 @@ module Cities
|
|
273
281
|
def updatetype
|
274
282
|
sql = "UPDATE #{self.class.mother_class.table_name} SET #{self.class.inheritance_column} = '#{self.class.to_s}' WHERE id = #{self.id}"
|
275
283
|
self.connection.execute(sql)
|
276
|
-
puts"#{sql}"
|
284
|
+
puts"#{sql}"
|
277
285
|
end
|
278
|
-
|
286
|
+
|
287
|
+
|
279
288
|
def destroy
|
280
289
|
super
|
281
290
|
if self.class.respond_to?('has_a_part_of?')
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 6
|
9
|
+
version: 0.0.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Laurent Buffat & Pierre-Emmanuel JOUVE
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-05-18 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|