dynamic-active-model 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dynamic-active-model/database.rb +21 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db4f6bee0035811fcf98c56f740c9c87a6151f20b30ac1e72605232f480e4766
|
4
|
+
data.tar.gz: 49e37d2abca94db6fa593fac3732767dcf2b12a37f05b3a5ff82be6c192c3dcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f6f1486e57a7a869cd700c1bf235b9915173723063291ed6e28a19529f6c4a8f486936e19e764f2d10297e48bf3a9a3301bae7d11a4d1fdba3d29e952504697
|
7
|
+
data.tar.gz: 7c49634233a7faf0a47f27abed7acaf6b01a0a77c8dd9b86c7147b1d4b23e57680123622d31eee575ce211f184b729a35c64f48e9ec4f55618ca614601cf819b
|
@@ -13,6 +13,8 @@ module DynamicActiveModel
|
|
13
13
|
@table_class_names = {}
|
14
14
|
@skip_tables = []
|
15
15
|
@skip_table_matchers = []
|
16
|
+
@include_tables = []
|
17
|
+
@include_table_matchers = []
|
16
18
|
@models = []
|
17
19
|
end
|
18
20
|
|
@@ -24,6 +26,14 @@ module DynamicActiveModel
|
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
29
|
+
def include_table(table)
|
30
|
+
if table.is_a?(Regexp)
|
31
|
+
@include_table_matchers << table
|
32
|
+
else
|
33
|
+
@include_tables << table
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
27
37
|
def table_class_name(table_name, class_name)
|
28
38
|
@table_class_names[table_name.to_s] = class_name
|
29
39
|
end
|
@@ -31,6 +41,7 @@ module DynamicActiveModel
|
|
31
41
|
def create_models!
|
32
42
|
@factory.base_class.connection.tables.each do |table_name|
|
33
43
|
next if skip_table?(table_name)
|
44
|
+
next unless include_table?(table_name)
|
34
45
|
|
35
46
|
@models << @factory.create(table_name, @table_class_names[table_name])
|
36
47
|
end
|
@@ -40,11 +51,21 @@ module DynamicActiveModel
|
|
40
51
|
@skip_tables + @skip_table_matchers
|
41
52
|
end
|
42
53
|
|
54
|
+
def include_tables
|
55
|
+
@include_tables + @include_table_matchers
|
56
|
+
end
|
57
|
+
|
43
58
|
private
|
44
59
|
|
45
60
|
def skip_table?(table_name)
|
46
61
|
@skip_tables.include?(table_name) ||
|
47
62
|
@skip_table_matchers.any? { |r| r.match(table_name) }
|
48
63
|
end
|
64
|
+
|
65
|
+
def include_table?(table_name)
|
66
|
+
(@include_tables.empty? && @include_table_matchers.empty?) ||
|
67
|
+
@include_tables.include?(table_name) ||
|
68
|
+
@include_table_matchers.any? { |r| r.match(table_name) }
|
69
|
+
end
|
49
70
|
end
|
50
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamic-active-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Youch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|