codegen 0.0.3 → 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/codegen/sources/active_record.rb +14 -6
- data/lib/codegen/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0b58cc33ca1e7f1b22e8dd362633a7444549f29
|
4
|
+
data.tar.gz: 4a8612e636bb5a9691912fa8655ac63b3086ecc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4df1d0a09d4aa33133d4310a96c2cc2468e81865f48bae77ae0937145e2ff24f1624ecce52e70995ec386eb649cf04d26bcc84f82ba08a66861a0f2f92a09907
|
7
|
+
data.tar.gz: 981bc92c47980c0be407cec0ac3ab6d6e63c9a98499137822af7031c639bb58a36504514b1001b0425bfdbd3debf78a9758dddc5565a2766dca19e31457a9ac3
|
@@ -1,5 +1,9 @@
|
|
1
|
+
|
2
|
+
|
1
3
|
module Codegen
|
2
4
|
module Sources
|
5
|
+
|
6
|
+
|
3
7
|
class ActiveRecord < Base
|
4
8
|
|
5
9
|
converts_to :entity
|
@@ -15,12 +19,16 @@ module Codegen
|
|
15
19
|
models = options[:models] || collect_all_models
|
16
20
|
models_and_methods = models.map { |model|
|
17
21
|
{
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
+
begin
|
23
|
+
model => {
|
24
|
+
methods: model_methods(model),
|
25
|
+
relations: model_relations(model)
|
26
|
+
}
|
27
|
+
rescue Exception => e
|
28
|
+
nil
|
29
|
+
end
|
22
30
|
}
|
23
|
-
}
|
31
|
+
}.filter { |x| x.nil? }
|
24
32
|
|
25
33
|
models_and_methods.map { |mm|
|
26
34
|
model_to_entity(mm)
|
@@ -71,7 +79,7 @@ module Codegen
|
|
71
79
|
def collect_all_models
|
72
80
|
begin
|
73
81
|
Rails.application.eager_load! if defined?(Rails)
|
74
|
-
ActiveRecord::Base.subclasses
|
82
|
+
::ActiveRecord::Base.subclasses
|
75
83
|
rescue
|
76
84
|
[]
|
77
85
|
end
|
data/lib/codegen/version.rb
CHANGED