effective_resources 1.8.37 → 1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/effective/resources/forms.rb +2 -0
- data/app/models/effective/resources/generator.rb +19 -0
- data/app/models/effective/resources/init.rb +6 -1
- data/app/models/effective/resources/klass.rb +40 -19
- data/lib/effective_resources/effective_gem.rb +5 -4
- data/lib/effective_resources/version.rb +1 -1
- 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: 010a64ad908bb27807756924d3f05112c7910568615678bcc8c99b04c7c69f93
|
4
|
+
data.tar.gz: cee9d5812ee210d09a8481c3261b625db6f7cf9b86d36fb261623d5e4fda2145
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72c9617fedc1420ec4b520328d66e92d765691d943c4ed0d0f6b642e876a74d9d2a11f3a9be16003a1fa8540dc20b43617b9f8dec740625010b7cacf37b1f63b
|
7
|
+
data.tar.gz: 7a9e7735119fc14caf02d6cee1e0fe1e9558888fc6ca7df4d33c95f073d28b7422adbb0fd93092391067b8ccd06dcb8eb8708a2017dafac5e5375103aa055d92
|
@@ -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
|
@@ -6,7 +8,10 @@ module Effective
|
|
6
8
|
|
7
9
|
def _initialize_input(input, namespace: nil, relation: nil)
|
8
10
|
@initialized_name = input
|
9
|
-
|
11
|
+
|
12
|
+
# Sets the class but also namespaces
|
13
|
+
@model_klass = _klass_by_input(input)
|
14
|
+
@model_klass = _klass_by_input(relation) if relation.present?
|
10
15
|
|
11
16
|
# Consider controller_name
|
12
17
|
if @model_klass && input.kind_of?(String) && namespace.blank?
|
@@ -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
|
-
|
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
|
@@ -8,22 +8,23 @@ module EffectiveGem
|
|
8
8
|
|
9
9
|
config_keys.each do |key|
|
10
10
|
self.singleton_class.define_method(key) { config()[key] }
|
11
|
+
self.singleton_class.define_method("#{key}=") { |value| config()[key] = value }
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
14
15
|
module ClassMethods
|
15
16
|
def config(namespace = nil)
|
16
17
|
namespace ||= Tenant.current if defined?(Tenant)
|
17
|
-
@config.dig(namespace) || @config
|
18
|
+
@config.dig(namespace) || @config.dig(:effective)
|
18
19
|
end
|
19
20
|
|
20
21
|
def setup(namespace = nil, &block)
|
21
22
|
@config ||= ActiveSupport::OrderedOptions.new
|
23
|
+
|
22
24
|
namespace ||= Tenant.current if defined?(Tenant)
|
25
|
+
namespace ||= :effective
|
23
26
|
|
24
|
-
|
25
|
-
@config[namespace] ||= ActiveSupport::OrderedOptions.new
|
26
|
-
end
|
27
|
+
@config[namespace] ||= ActiveSupport::OrderedOptions.new
|
27
28
|
|
28
29
|
yield(config(namespace))
|
29
30
|
|
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.
|
4
|
+
version: 1.9.2
|
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-
|
11
|
+
date: 2021-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|