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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc4b3959711130ff5e711c91a8a3ae30f996dcbbf83c98a6d2bb108ffed665e6
4
- data.tar.gz: c5090823346eb41d62bb400cce5b7c4c4c17b9a9261017aa374a31fa33ca3630
3
+ metadata.gz: e1189d1c955046a61940254f58bc78e3743e51e912a6c1e1443ffa9d4df8b22e
4
+ data.tar.gz: 69cbcc3fcc34ee51c03979896f6862ada18d9bd410c297141d14959009e5f38f
5
5
  SHA512:
6
- metadata.gz: c46b67ac2fe96276806252c3c56e0472b32b6f91aa2351dd7d8ae76485de59260e2079dd42336c61beb1d28de9f6c0177e32e60d9a5e35c9b7dd8b9e770ff0bf
7
- data.tar.gz: d49105316054eab5561cfbbad123cf4e106d7d837446cab63f91149f225022466c7ef3e10442e20789c4c920e9a222dbf27ad552a253cd23267e71356d34fa68
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
- lambda {
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Motor
4
- VERSION = '0.2.18'
4
+ VERSION = '0.2.19'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motor-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.18
4
+ version: 0.2.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Matsyburka