active-dbml 0.2.0 → 0.2.3
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 +4 -4
- data/lib/active/dbml/version.rb +1 -1
- data/lib/active/dbml.rb +24 -20
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 883f97dab6da278ac16901b94d60b2288cbcad0dc84fda907c6f316fd4de5859
|
4
|
+
data.tar.gz: bf8cf386d3a53c7aa3dd04f5704ab50fa6fbb695d1c81eeeb266d109d416bbad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60e2e63cbd3c2c932430388a6c99bb8ba7a634097e50cbe9d0c0c950c13d1cdd0885f9bf28140d139156ab61c418fe36cdf69b63939757a9035face489641184
|
7
|
+
data.tar.gz: 00ab782368ffdeabbd31b0e3c2ee94d1a08dc23ee5aed42456eb4233e9864d94d4b0583c7d4c396d0d947316f3a3f3f9c19c2c0aa5301a10824add607c380e85
|
data/lib/active/dbml/version.rb
CHANGED
data/lib/active/dbml.rb
CHANGED
@@ -62,29 +62,33 @@ module Active
|
|
62
62
|
|
63
63
|
# get foreign key only belongs_to association
|
64
64
|
model.reflect_on_all_associations(:belongs_to).each do |association|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
65
|
+
begin
|
66
|
+
# NOTE: Check model type
|
67
|
+
# Skip anything other than ActiveRecord::Base
|
68
|
+
if association.class_name.constantize < ActiveRecord::Base
|
69
|
+
association.class_name.constantize.reflect_on_all_associations.each do |relation_association|
|
70
|
+
if model.table_name.eql?(relation_association.plural_name)
|
71
|
+
foreign_key = association.options[:foreign_key]
|
72
|
+
foreign_key_destination = "#{association.plural_name}.#{association.class_name.constantize.primary_key}"
|
73
|
+
|
74
|
+
case relation_association.macro
|
75
|
+
when :has_one
|
76
|
+
foreign_keys[foreign_key] = { destination: foreign_key_destination, relation_type: '-' }
|
77
|
+
when :has_many
|
78
|
+
foreign_keys[foreign_key] = { destination: foreign_key_destination, relation_type: '>' }
|
79
|
+
else
|
80
|
+
end
|
79
81
|
end
|
80
82
|
end
|
83
|
+
elsif association.class_name.constantize < ActiveYaml::Base
|
84
|
+
puts "⚠ #{association.class_name.constantize} is an ActiveYaml model."
|
85
|
+
elsif association.class_name.constantize < ActiveHash::Base
|
86
|
+
puts "⚠ #{association.class_name.constantize} is an ActiveHash model."
|
87
|
+
else
|
88
|
+
puts "⚠ Cannot determine type of #{association.class_name.constantize}"
|
81
89
|
end
|
82
|
-
|
83
|
-
|
84
|
-
elsif association.class_name.constantize < ActiveHash::Base
|
85
|
-
puts "⚠ #{association.class_name.constantize} is an ActiveHash model."
|
86
|
-
else
|
87
|
-
puts "⚠ Cannot determine type of #{association.class_name.constantize}"
|
90
|
+
rescue => exception
|
91
|
+
Rails.logger.error exception
|
88
92
|
end
|
89
93
|
end
|
90
94
|
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-dbml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ukmshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '6'
|
27
27
|
description: Active::DBML is a new, useful Ruby gem designed to streamline database
|