multi_tabular 0.0.2 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92cbe3c16e1fc9900bea20bb3639e58ebc986ba3
4
- data.tar.gz: 4c0b92455f9d66494462fae3df726388f77144b2
3
+ metadata.gz: 9197583d5aa69ee835744afa733e81a644b1638d
4
+ data.tar.gz: 6fb7cf658217c52422373fc30bb40ff48b4b574d
5
5
  SHA512:
6
- metadata.gz: 507ccebc9e858d9dc1ef6369eddc49d0cd25840c64e90120fa91c11c6ecf5e9e54fd231bec76394ed5791fc6a02ece1eed7d2ab1cf438f836faf976847965e85
7
- data.tar.gz: b3e5d0b1702d0a503c748ac62192889859bf9fe48131215f8642ec83757f0474f4c9955221b82cdc57dd466c18781e1c1c4abd61cf02349da10b6866ea6f8551
6
+ metadata.gz: 3ce5a4df015b72f2af3b149b0d1c88a81ebcb34c74e6b57467ec0071e54270eab3d744a93269c255ab9fe463c9f35bc527d0ae9aa9a515a51379fec1264823ac
7
+ data.tar.gz: 3bd9984ebe80303ebb4e11c9aed26dd19d75f782ad9cd1fe6471759dcd8073bc852308f18fe592444ba2041274caee96fda1c7b72acd894fe2592e88c17cb5c6
data/lib/multi_tabular.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'multi_tabular/references'
2
2
  require 'multi_tabular/super'
3
- require 'multi_tabular/sub'
4
3
  require 'multi_tabular/version'
5
4
 
6
5
  module MultiTabular
@@ -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
- extend ActiveSupport::Concern
6
+ def self.included(base)
7
+ base.abstract_class = true
7
8
 
8
- included do
9
- self.abstract_class = true
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
- # Allow converting the class name to an assumed foreign key in an associated model's database.
12
- # If a different foreign should be used, you can override this method or simply declare the foreign key manually.
13
- def self.to_foreign_key
14
- name.underscore.sub('/', '_').singularize << '_id'
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
@@ -1,3 +1,3 @@
1
1
  module MultiTabular
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.4'
3
3
  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.2
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:
@@ -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