motor-admin 0.2.18 → 0.2.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/motor/resources/fetch_configured_model.rb +17 -10
- data/lib/motor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1189d1c955046a61940254f58bc78e3743e51e912a6c1e1443ffa9d4df8b22e
|
4
|
+
data.tar.gz: 69cbcc3fcc34ee51c03979896f6862ada18d9bd410c297141d14959009e5f38f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57f991559988e88d2a8abc00bc302946dc986fa75b5e6bc6953a1d05552810339a95d5ef5aae8b0c3bc98c806d7ecfc1b2bacf051471fd2088e10594c8e6fed6
|
7
|
+
data.tar.gz: d72ff24ee69ea6db86585efb92dfab69582fb6c712d12c97b19bbd16f5a506b41e72f95d1fea05a153fa430e9a1c014542db8e684dc91dd948027ae9464a5b73
|
@@ -10,26 +10,19 @@ module Motor
|
|
10
10
|
def call(model, cache_key:)
|
11
11
|
configs = Motor::Configs::LoadFromCache.load_resources(cache_key: cache_key)
|
12
12
|
|
13
|
-
return model if configs.blank?
|
13
|
+
return model if configs.blank? || sti_model?(model)
|
14
14
|
|
15
15
|
maybe_fetch_from_cache(
|
16
16
|
model,
|
17
17
|
cache_key.to_s + model.object_id.to_s,
|
18
|
-
|
19
|
-
resource_config = configs.find { |r| r.name == model.name.underscore }
|
20
|
-
|
21
|
-
if resource_config
|
22
|
-
build_configured_model(model, resource_config.preferences)
|
23
|
-
else
|
24
|
-
define_class_name_method(Class.new(model), model)
|
25
|
-
end
|
26
|
-
},
|
18
|
+
-> { build_configured_model_from_configs(model, configs) },
|
27
19
|
->(klass) { configure_reflection_classes(klass, cache_key) }
|
28
20
|
)
|
29
21
|
end
|
30
22
|
|
31
23
|
def build_configured_model(model, config)
|
32
24
|
klass = Class.new(model)
|
25
|
+
klass.inheritance_column = nil if model.superclass.abstract_class
|
33
26
|
|
34
27
|
define_class_name_method(klass, model)
|
35
28
|
|
@@ -199,6 +192,20 @@ module Motor
|
|
199
192
|
postprocess_block.call(result)
|
200
193
|
end
|
201
194
|
end
|
195
|
+
|
196
|
+
def build_configured_model_from_configs(model, configs)
|
197
|
+
resource_config = configs.find { |r| r.name == model.name.underscore }
|
198
|
+
|
199
|
+
if resource_config
|
200
|
+
build_configured_model(model, resource_config.preferences)
|
201
|
+
else
|
202
|
+
define_class_name_method(Class.new(model), model)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def sti_model?(model)
|
207
|
+
!model.superclass.abstract_class && model.columns_hash[model.inheritance_column.to_s]
|
208
|
+
end
|
202
209
|
end
|
203
210
|
end
|
204
211
|
end
|
data/lib/motor/version.rb
CHANGED