active-dbml 0.2.0 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9ba556246418cfc6c5280d60b646b824fe76c2118fc8506e7b82bba21b29ae5
4
- data.tar.gz: e8d7e89de5d7bb090a8388e6a97c946cd349d032d6ad8ae701f089c15f340d36
3
+ metadata.gz: 883f97dab6da278ac16901b94d60b2288cbcad0dc84fda907c6f316fd4de5859
4
+ data.tar.gz: bf8cf386d3a53c7aa3dd04f5704ab50fa6fbb695d1c81eeeb266d109d416bbad
5
5
  SHA512:
6
- metadata.gz: ae0f2a620ca97b9694801c1ca7ed3693a38aadf3bd66317272f2020d56f794be494e63bec73b9cb9dfb9b49306c037efd2e16190b8a38197466210da7c9ef4ec
7
- data.tar.gz: e15bff16d349029e10a603e77462a3f0a965c06b967f83ee27ff505fb18701f0289c37d6dbd93a525a8a78059050b29bea26f666fff11c102de7d74a85cd5d08
6
+ metadata.gz: 60e2e63cbd3c2c932430388a6c99bb8ba7a634097e50cbe9d0c0c950c13d1cdd0885f9bf28140d139156ab61c418fe36cdf69b63939757a9035face489641184
7
+ data.tar.gz: 00ab782368ffdeabbd31b0e3c2ee94d1a08dc23ee5aed42456eb4233e9864d94d4b0583c7d4c396d0d947316f3a3f3f9c19c2c0aa5301a10824add607c380e85
@@ -1,5 +1,5 @@
1
1
  module Active
2
2
  module Dbml
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  end
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
- foreign_key = association.options[:foreign_key]
66
- foreign_key_destination = "#{association.plural_name}.#{association.class_name.constantize.primary_key}"
67
-
68
- # NOTE: Check model type
69
- # Skip anything other than ActiveRecord::Base
70
- if association.class_name.constantize < ActiveRecord::Base
71
- association.class_name.constantize.reflect_on_all_associations.each do |relation_association|
72
- if model.table_name.eql?(relation_association.plural_name)
73
- case relation_association.macro
74
- when :has_one
75
- foreign_keys[foreign_key] = { destination: foreign_key_destination, relation_type: '-' }
76
- when :has_many
77
- foreign_keys[foreign_key] = { destination: foreign_key_destination, relation_type: '>' }
78
- else
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
- elsif association.class_name.constantize < ActiveYaml::Base
83
- puts "⚠ #{association.class_name.constantize} is an ActiveYaml model."
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.0
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-06-01 00:00:00.000000000 Z
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