effective_resources 1.9.0 → 1.9.1

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: e170a1dbe4e16bf76c3048540a98601f3944fb624ba7f6dc50a25d31d0c6b528
4
- data.tar.gz: 3e0c48d4caa389595a6b77f7ab7f6ad00c469d397e0962d443ec04a8129d73cb
3
+ metadata.gz: d4e5791f81c07c0f264f6c4d91d4cb3e01c0194577457ae38239cfafd99ae6a6
4
+ data.tar.gz: 5e82bcba8a50e8b9beceffa977241c95000805690f02343aad7ffef7a66d0f97
5
5
  SHA512:
6
- metadata.gz: ea9eefce2138894165ba88a81f5fbefa0edd500046aed321bd11ad6b93181b5cc9a36ba51668d869b59043e629c71577e026a97dd9667117f864db7b3199eaa9
7
- data.tar.gz: f01e4bcef353c0fd5865b4cb046eb3814acf7172c357b8f2b6b7a9f9456f3209d1a13f0931ed67bb7804e891e6a79aab7ef774b85996d7f07e5872e0b84069db
6
+ metadata.gz: 14a3dce0969cf7487a9f950a11b8fc8cd696b5dd01253c1d89792ed1c804af08b8ba886ce640e118e5f75e1ab47a6ff500c4dd3feca75ecacc1b3f5e9646e2ec
7
+ data.tar.gz: 72546fd49b52e4da7c713bcadf0179438d2f91fae66d9a99d09f08a35d96a71eb149d107add609b9232dc666af8866482e7f7a5d365d00b0af06af03e06cb2a5
@@ -1,3 +1,5 @@
1
+ # frozen_sting_literals: true
2
+
1
3
  module Effective
2
4
  module Resources
3
5
  module Forms
@@ -1,3 +1,5 @@
1
+ # frozen_sting_literals: true
2
+
1
3
  module Effective
2
4
  module Resources
3
5
  module Generator
@@ -26,6 +28,23 @@ module Effective
26
28
  Array(namespaces).map { |name| name.to_s.classify }.join('::') + '::' + class_name.gsub('::', '')
27
29
  end
28
30
 
31
+ # Tenants
32
+ def tenant_controller_path
33
+ (Tenant.module_name.downcase + '/' + controller_path) if defined?(Tenant)
34
+ end
35
+
36
+ def tenant_namespaced_class_name
37
+ (Tenant.module_name + '::' + namespaced_class_name) if defined?(Tenant)
38
+ end
39
+
40
+ def tenant_namespaced_module_name
41
+ (Tenant.module_name + '::' + namespaced_module_name) if defined?(Tenant)
42
+ end
43
+
44
+ def tenant_class_name
45
+ (Tenant.module_name + '::' + class_name) if defined?(Tenant)
46
+ end
47
+
29
48
  end
30
49
  end
31
50
  end
@@ -1,3 +1,5 @@
1
+ # frozen_sting_literals: true
2
+
1
3
  module Effective
2
4
  module Resources
3
5
  module Init
@@ -7,28 +7,11 @@ module Effective
7
7
  end
8
8
 
9
9
  def datatable_klass
10
- if defined?(EffectiveDatatables)
11
- "#{controller_path.classify.pluralize}Datatable".safe_constantize ||
12
- "#{controller_path.classify}Datatable".safe_constantize ||
13
- "#{namespaced_class_name.pluralize}Datatable".safe_constantize ||
14
- "#{namespaced_module_name.pluralize}Datatable".safe_constantize ||
15
- "#{namespaced_class_name.pluralize.gsub('::', '')}Datatable".safe_constantize ||
16
- "#{class_name.pluralize.camelize}Datatable".safe_constantize ||
17
- "#{class_name.pluralize.camelize.gsub('::', '')}Datatable".safe_constantize ||
18
- "#{name.pluralize.camelize}Datatable".safe_constantize ||
19
- "#{name.pluralize.camelize.gsub('::', '')}Datatable".safe_constantize ||
20
- "Effective::Datatables::#{namespaced_class_name.pluralize}".safe_constantize ||
21
- "Effective::Datatables::#{class_name.pluralize.camelize}".safe_constantize ||
22
- "Effective::Datatables::#{name.pluralize.camelize}".safe_constantize
23
- end
10
+ (find_tenant_datatable_klass || find_datatable_klass) if defined?(EffectiveDatatables)
24
11
  end
25
12
 
26
13
  def controller_klass
27
- "#{namespaced_class_name.pluralize}Controller".safe_constantize ||
28
- "#{class_name.pluralize.classify}Controller".safe_constantize ||
29
- "#{name.pluralize.classify}Controller".safe_constantize ||
30
- "#{initialized_name.to_s.classify.pluralize}Controller".safe_constantize ||
31
- "#{initialized_name.to_s.classify}Controller".safe_constantize
14
+ find_controller_klass
32
15
  end
33
16
 
34
17
  def active_record?
@@ -39,6 +22,44 @@ module Effective
39
22
  klass && klass.ancestors.include?(ActiveModel::Model)
40
23
  end
41
24
 
25
+ private
26
+
27
+ def find_datatable_klass
28
+ "::#{controller_path.classify.pluralize}Datatable".safe_constantize ||
29
+ "::#{controller_path.classify}Datatable".safe_constantize ||
30
+ "::#{namespaced_class_name.pluralize}Datatable".safe_constantize ||
31
+ "::#{namespaced_module_name.pluralize}Datatable".safe_constantize ||
32
+ "::#{namespaced_class_name.pluralize.gsub('::', '')}Datatable".safe_constantize ||
33
+ "::#{class_name.pluralize.camelize}Datatable".safe_constantize ||
34
+ "::#{class_name.pluralize.camelize.gsub('::', '')}Datatable".safe_constantize ||
35
+ "::#{name.pluralize.camelize}Datatable".safe_constantize ||
36
+ "::#{name.pluralize.camelize.gsub('::', '')}Datatable".safe_constantize ||
37
+ "::Effective::Datatables::#{namespaced_class_name.pluralize}".safe_constantize ||
38
+ "::Effective::Datatables::#{class_name.pluralize.camelize}".safe_constantize ||
39
+ "::Effective::Datatables::#{name.pluralize.camelize}".safe_constantize
40
+ end
41
+
42
+ def find_tenant_datatable_klass
43
+ return unless defined?(Tenant)
44
+
45
+ "::#{tenant_controller_path.classify.pluralize}Datatable".safe_constantize ||
46
+ "::#{tenant_controller_path.classify}Datatable".safe_constantize ||
47
+ "::#{tenant_namespaced_class_name.pluralize}Datatable".safe_constantize ||
48
+
49
+ "::#{tenant_namespaced_module_name.pluralize}Datatable".safe_constantize ||
50
+ "::#{tenant_namespaced_class_name.pluralize.gsub('::', '')}Datatable".safe_constantize ||
51
+ "::#{tenant_class_name.pluralize.camelize}Datatable".safe_constantize ||
52
+ "::#{tenant_class_name.pluralize.camelize.gsub('::', '')}Datatable".safe_constantize
53
+ end
54
+
55
+ def find_controller_klass
56
+ "#{namespaced_class_name.pluralize}Controller".safe_constantize ||
57
+ "#{class_name.pluralize.classify}Controller".safe_constantize ||
58
+ "#{name.pluralize.classify}Controller".safe_constantize ||
59
+ "#{initialized_name.to_s.classify.pluralize}Controller".safe_constantize ||
60
+ "#{initialized_name.to_s.classify}Controller".safe_constantize
61
+ end
62
+
42
63
  end
43
64
  end
44
65
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.9.0'.freeze
2
+ VERSION = '1.9.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-25 00:00:00.000000000 Z
11
+ date: 2021-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails