multi_tabular 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/multi_tabular.rb +0 -1
- data/lib/multi_tabular/super.rb +15 -7
- data/lib/multi_tabular/version.rb +1 -1
- metadata +1 -2
- data/lib/multi_tabular/sub.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9197583d5aa69ee835744afa733e81a644b1638d
|
4
|
+
data.tar.gz: 6fb7cf658217c52422373fc30bb40ff48b4b574d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ce5a4df015b72f2af3b149b0d1c88a81ebcb34c74e6b57467ec0071e54270eab3d744a93269c255ab9fe463c9f35bc527d0ae9aa9a515a51379fec1264823ac
|
7
|
+
data.tar.gz: 3bd9984ebe80303ebb4e11c9aed26dd19d75f782ad9cd1fe6471759dcd8073bc852308f18fe592444ba2041274caee96fda1c7b72acd894fe2592e88c17cb5c6
|
data/lib/multi_tabular.rb
CHANGED
data/lib/multi_tabular/super.rb
CHANGED
@@ -3,15 +3,23 @@ module MultiTabular
|
|
3
3
|
# These classes can provide shared logic, but are not an activerecord-model on their own,
|
4
4
|
# meaning they have no corresponding table in the database.
|
5
5
|
module Super
|
6
|
-
|
6
|
+
def self.included(base)
|
7
|
+
base.abstract_class = true
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
def base.inherited(child)
|
10
|
+
# Allow converting the class name to an assumed foreign key in an associated model's database.
|
11
|
+
# If a different foreign should be used, you can override this method or simply declare the foreign key manually.
|
12
|
+
def child.to_foreign_key
|
13
|
+
name.underscore.sub('/', '_').singularize << '_id'
|
14
|
+
end
|
10
15
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
return if self.eql?(child)
|
17
|
+
if self.respond_to?(:inherited_associations)
|
18
|
+
self.inherited_associations(child)
|
19
|
+
end
|
20
|
+
|
21
|
+
# TODO make this work
|
22
|
+
# child.table_name = child.name.underscore.sub('/', '_').pluralize
|
15
23
|
end
|
16
24
|
end
|
17
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_tabular
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Junger
|
@@ -49,7 +49,6 @@ files:
|
|
49
49
|
- Gemfile
|
50
50
|
- lib/multi_tabular.rb
|
51
51
|
- lib/multi_tabular/references.rb
|
52
|
-
- lib/multi_tabular/sub.rb
|
53
52
|
- lib/multi_tabular/super.rb
|
54
53
|
- lib/multi_tabular/version.rb
|
55
54
|
homepage:
|
data/lib/multi_tabular/sub.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
module MultiTabular
|
2
|
-
# For subclasses of an MTI construct.
|
3
|
-
# These classes inherit logic from a superclass and are persisted in their own table.
|
4
|
-
module Sub
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
# Set the table name to be the class name, including namespaces.
|
8
|
-
# If a different table should be used, override this variable in your class.
|
9
|
-
included do
|
10
|
-
self.table_name = name.underscore.sub('/', '_').pluralize
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|