citier 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/citier.gemspec +1 -1
- data/lib/citier/child_instance_methods.rb +1 -0
- data/lib/citier/class_methods.rb +6 -9
- data/lib/citier/sql_adapters.rb +3 -9
- metadata +3 -3
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('citier', '0.1.
|
5
|
+
Echoe.new('citier', '0.1.11') do |p|
|
6
6
|
p.description = "CITIER (Class Inheritance & Table Inheritance Embeddings for Rails) is a solution for single and multiple class table inheritance.
|
7
7
|
For full information: http://peterhamilton.github.com/citier/
|
8
8
|
For the original version by ALTRABio see www.github.com/altrabio/"
|
data/citier.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{citier}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.11"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Peter Hamilton, Originally from Laurent Buffat, Pierre-Emmanuel Jouve"]
|
@@ -29,6 +29,7 @@ module ChildInstanceMethods
|
|
29
29
|
# and parent(s) saved successfully, save current model
|
30
30
|
if(!attributes_for_current.empty? && parent_saved)
|
31
31
|
current = self.class::Writable.new(attributes_for_current)
|
32
|
+
current.id = self.id
|
32
33
|
current.is_new_record(new_record?)
|
33
34
|
current_saved = current.save
|
34
35
|
|
data/lib/citier/class_methods.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
module ClassMethods
|
2
2
|
# any method placed here will apply to classes
|
3
|
-
|
4
|
-
|
5
3
|
def acts_as_citier(options = {})
|
6
4
|
|
7
5
|
# Option for setting the inheritance columns, default value = 'type'
|
@@ -30,7 +28,7 @@ module ClassMethods
|
|
30
28
|
# Add the functions required for children only
|
31
29
|
send :include, ChildInstanceMethods
|
32
30
|
else
|
33
|
-
|
31
|
+
# Root class
|
34
32
|
|
35
33
|
after_save :updatetype
|
36
34
|
|
@@ -39,17 +37,16 @@ module ClassMethods
|
|
39
37
|
set_table_name "#{table_name}"
|
40
38
|
|
41
39
|
citier_debug("table_name -> #{self.table_name}")
|
42
|
-
|
43
|
-
#returns the root class (the highest inherited class before ActiveRecord)
|
40
|
+
#returns the root class (the highest inherited class before ActiveRecord)
|
44
41
|
def self.root_class
|
45
|
-
if(self.superclass!=ActiveRecord::Base)
|
46
|
-
|
42
|
+
if(self.superclass!=ActiveRecord::Base)
|
43
|
+
self.superclass.root_class
|
47
44
|
else
|
48
|
-
|
45
|
+
return self
|
49
46
|
end
|
50
47
|
end
|
51
48
|
|
52
|
-
def self.find(*args) #overrides find to get all attributes
|
49
|
+
def self.find(*args) #overrides find to get all attributes
|
53
50
|
tuples = super
|
54
51
|
|
55
52
|
# in case of many objects, return an array of them, reloaded to pull in inherited attributes
|
data/lib/citier/sql_adapters.rb
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
# #
|
6
6
|
#------------------------------------------------------------------------------------------------#
|
7
7
|
|
8
|
-
# SQLite
|
9
|
-
|
10
8
|
require 'active_record'
|
11
9
|
require 'active_record/connection_adapters/sqlite_adapter'
|
12
10
|
require 'active_record/connection_adapters/sqlite3_adapter'
|
13
11
|
require 'active_record/connection_adapters/postgresql_adapter'
|
12
|
+
|
13
|
+
# SQLite
|
14
14
|
module ActiveRecord
|
15
15
|
module ConnectionAdapters
|
16
16
|
class SQLiteAdapter < AbstractAdapter
|
@@ -41,12 +41,10 @@ module ActiveRecord
|
|
41
41
|
class PostgreSQLAdapter < AbstractAdapter
|
42
42
|
def tables(name = nil)
|
43
43
|
a=tablesL(name)
|
44
|
-
puts("1------>#{a}")
|
45
44
|
b=viewsL(name)
|
46
45
|
if(b!=[])
|
47
46
|
a=a+b
|
48
47
|
end
|
49
|
-
puts("2------>#{a}")
|
50
48
|
return a
|
51
49
|
end
|
52
50
|
|
@@ -70,8 +68,6 @@ module ActiveRecord
|
|
70
68
|
def table_exists?(name)
|
71
69
|
a=table_existsB?(name)
|
72
70
|
b=views_existsB?(name)
|
73
|
-
puts"T---->#{a}"
|
74
|
-
puts"T---->#{b}"
|
75
71
|
return a||b
|
76
72
|
end
|
77
73
|
|
@@ -124,8 +120,6 @@ module ActiveRecord
|
|
124
120
|
end
|
125
121
|
end
|
126
122
|
|
127
|
-
|
128
|
-
|
129
123
|
# MySQL
|
130
124
|
# No Modification needed, this essentially comes from the fact that MySQL "show" command
|
131
|
-
# lists
|
125
|
+
# lists tables & views simultaneously
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: citier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 11
|
10
|
+
version: 0.1.11
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Peter Hamilton, Originally from Laurent Buffat, Pierre-Emmanuel Jouve
|