wallaby-core 0.2.11 → 0.3.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/wallaby/resources_controller.rb +20 -7
- data/app/security/ability.rb +1 -1
- data/config/routes.rb +21 -14
- data/lib/adaptors/wallaby/custom/default_provider.rb +1 -1
- data/lib/adaptors/wallaby/custom/model_decorator.rb +5 -17
- data/lib/adaptors/wallaby/custom/model_finder.rb +3 -3
- data/lib/adaptors/wallaby/custom/model_pagination_provider.rb +1 -1
- data/lib/adaptors/wallaby/custom/model_service_provider.rb +1 -1
- data/lib/authorizers/wallaby/cancancan_authorization_provider.rb +12 -5
- data/lib/authorizers/wallaby/default_authorization_provider.rb +10 -1
- data/lib/authorizers/wallaby/model_authorizer.rb +41 -16
- data/lib/authorizers/wallaby/pundit_authorization_provider.rb +22 -8
- data/lib/concerns/wallaby/application_concern.rb +41 -71
- data/lib/concerns/wallaby/authentication_concern.rb +29 -127
- data/lib/concerns/wallaby/authorizable.rb +14 -57
- data/lib/concerns/wallaby/baseable.rb +24 -57
- data/lib/concerns/wallaby/configurable.rb +416 -0
- data/lib/concerns/wallaby/decoratable.rb +29 -60
- data/lib/concerns/wallaby/engineable.rb +29 -46
- data/lib/concerns/wallaby/fieldable.rb +45 -56
- data/lib/concerns/wallaby/paginatable.rb +20 -51
- data/lib/concerns/wallaby/prefixable.rb +24 -4
- data/lib/concerns/wallaby/resourcable.rb +130 -72
- data/lib/concerns/wallaby/resources_concern.rb +205 -305
- data/lib/concerns/wallaby/servicable.rb +8 -48
- data/lib/concerns/wallaby/urlable.rb +69 -0
- data/lib/decorators/wallaby/resource_decorator.rb +91 -34
- data/lib/errors/wallaby/class_not_found.rb +1 -2
- data/lib/errors/wallaby/forbidden.rb +1 -2
- data/lib/errors/wallaby/general_error.rb +1 -1
- data/lib/errors/wallaby/invalid_error.rb +1 -2
- data/lib/errors/wallaby/method_removed.rb +5 -0
- data/lib/errors/wallaby/model_not_found.rb +1 -2
- data/lib/errors/wallaby/not_authenticated.rb +1 -2
- data/lib/errors/wallaby/not_found.rb +1 -2
- data/lib/errors/wallaby/not_implemented.rb +1 -2
- data/lib/errors/wallaby/resource_not_found.rb +1 -2
- data/lib/errors/wallaby/unprocessable_entity.rb +1 -2
- data/lib/fields/wallaby/all_fields.rb +63 -0
- data/lib/forms/wallaby/form_builder.rb +1 -1
- data/lib/generators/wallaby/engine/application_generator.rb +33 -0
- data/lib/generators/wallaby/engine/authorizer/USAGE +20 -0
- data/lib/generators/wallaby/engine/authorizer/authorizer_generator.rb +19 -0
- data/lib/generators/wallaby/engine/authorizer/templates/authorizer.rb.erb +35 -0
- data/lib/generators/wallaby/engine/controller/USAGE +20 -0
- data/lib/generators/wallaby/engine/controller/controller_generator.rb +23 -0
- data/lib/generators/wallaby/engine/controller/templates/controller.rb.erb +130 -0
- data/lib/generators/wallaby/engine/decorator/USAGE +20 -0
- data/lib/generators/wallaby/engine/decorator/decorator_generator.rb +19 -0
- data/lib/generators/wallaby/engine/decorator/templates/decorator.rb.erb +5 -0
- data/lib/generators/wallaby/engine/install/USAGE +19 -0
- data/lib/generators/wallaby/engine/install/install_generator.rb +91 -0
- data/lib/generators/wallaby/engine/install/templates/application_authorizer.rb.erb +37 -0
- data/lib/generators/wallaby/engine/install/templates/application_controller.rb.erb +173 -0
- data/lib/generators/wallaby/engine/install/templates/application_decorator.rb.erb +7 -0
- data/lib/generators/wallaby/engine/install/templates/application_paginator.rb.erb +27 -0
- data/lib/generators/wallaby/engine/install/templates/application_servicer.rb.erb +47 -0
- data/lib/generators/wallaby/engine/install/templates/initializer.rb.erb +16 -0
- data/lib/generators/wallaby/engine/paginator/USAGE +20 -0
- data/lib/generators/wallaby/engine/paginator/paginator_generator.rb +19 -0
- data/lib/generators/wallaby/engine/paginator/templates/paginator.rb.erb +25 -0
- data/lib/generators/wallaby/engine/servicer/USAGE +20 -0
- data/lib/generators/wallaby/engine/servicer/servicer_generator.rb +19 -0
- data/lib/generators/wallaby/engine/servicer/templates/servicer.rb.erb +45 -0
- data/lib/helpers/wallaby/application_helper.rb +10 -59
- data/lib/helpers/wallaby/base_helper.rb +11 -11
- data/lib/helpers/wallaby/configuration_helper.rb +36 -4
- data/lib/helpers/wallaby/form_helper.rb +1 -1
- data/lib/helpers/wallaby/index_helper.rb +19 -9
- data/lib/helpers/wallaby/links_helper.rb +18 -85
- data/lib/helpers/wallaby/resources_helper.rb +39 -7
- data/lib/helpers/wallaby/secure_helper.rb +20 -19
- data/lib/interfaces/wallaby/mode.rb +8 -8
- data/lib/interfaces/wallaby/model_authorization_provider.rb +23 -22
- data/lib/interfaces/wallaby/model_decorator.rb +36 -48
- data/lib/interfaces/wallaby/model_finder.rb +3 -3
- data/lib/interfaces/wallaby/model_pagination_provider.rb +2 -6
- data/lib/interfaces/wallaby/model_service_provider.rb +4 -4
- data/lib/paginators/wallaby/model_paginator.rb +1 -1
- data/lib/responders/wallaby/json_api_responder.rb +10 -5
- data/lib/responders/wallaby/resources_responder.rb +10 -3
- data/lib/routes/wallaby/engines/base_route.rb +78 -0
- data/lib/routes/wallaby/engines/custom_app_route.rb +92 -0
- data/lib/routes/wallaby/engines/engine_route.rb +77 -0
- data/lib/routes/wallaby/resources_router.rb +100 -45
- data/lib/servicers/wallaby/model_servicer.rb +13 -13
- data/lib/services/wallaby/authorizer_finder.rb +23 -0
- data/lib/services/wallaby/class_finder.rb +42 -0
- data/lib/services/wallaby/controller_finder.rb +29 -0
- data/lib/services/wallaby/decorator_finder.rb +34 -0
- data/lib/services/wallaby/default_models_excluder.rb +45 -0
- data/lib/services/wallaby/engine_name_finder.rb +14 -11
- data/lib/services/wallaby/engine_url_for.rb +82 -37
- data/lib/services/wallaby/fields_regulator.rb +34 -0
- data/lib/services/wallaby/map/mode_mapper.rb +5 -5
- data/lib/services/wallaby/map/model_class_mapper.rb +1 -1
- data/lib/services/wallaby/model_class_filter.rb +29 -0
- data/lib/services/wallaby/paginator_finder.rb +24 -0
- data/lib/services/wallaby/prefixes_builder.rb +49 -8
- data/lib/services/wallaby/servicer_finder.rb +31 -0
- data/lib/services/wallaby/sorting/hash_builder.rb +9 -0
- data/lib/services/wallaby/sorting/link_builder.rb +7 -10
- data/lib/services/wallaby/sorting/next_builder.rb +1 -12
- data/lib/services/wallaby/sorting/single_builder.rb +1 -1
- data/lib/support/action_dispatch/routing/mapper.rb +29 -4
- data/lib/utils/wallaby/field_utils.rb +9 -8
- data/lib/utils/wallaby/inflector.rb +94 -0
- data/lib/utils/wallaby/locale.rb +2 -2
- data/lib/utils/wallaby/module_utils.rb +3 -10
- data/lib/utils/wallaby/utils.rb +21 -14
- data/lib/wallaby/class_array.rb +18 -13
- data/lib/wallaby/class_hash.rb +16 -14
- data/lib/wallaby/classifier.rb +4 -2
- data/lib/wallaby/configuration/features.rb +8 -2
- data/lib/wallaby/configuration/mapping.rb +66 -112
- data/lib/wallaby/configuration/metadata.rb +15 -12
- data/lib/wallaby/configuration/models.rb +27 -25
- data/lib/wallaby/configuration/pagination.rb +15 -19
- data/lib/wallaby/configuration/security.rb +88 -80
- data/lib/wallaby/configuration/sorting.rb +15 -17
- data/lib/wallaby/configuration.rb +58 -23
- data/lib/wallaby/constants.rb +21 -13
- data/lib/wallaby/core/version.rb +1 -1
- data/lib/wallaby/core.rb +34 -10
- data/lib/wallaby/deprecator.rb +81 -0
- data/lib/wallaby/engine.rb +1 -18
- data/lib/wallaby/guesser.rb +45 -0
- data/lib/wallaby/logger.rb +35 -13
- data/lib/wallaby/map.rb +11 -88
- data/lib/wallaby/preloader.rb +8 -28
- metadata +113 -14
- data/config/locales/wallaby_class.en.yml +0 -9
- data/lib/concerns/wallaby/defaultable.rb +0 -38
- data/lib/concerns/wallaby/shared_helpers.rb +0 -22
- data/lib/services/wallaby/map/model_class_collector.rb +0 -49
- data/lib/services/wallaby/type_renderer.rb +0 -40
- data/lib/utils/wallaby/model_utils.rb +0 -52
- data/lib/utils/wallaby/test_utils.rb +0 -34
data/lib/utils/wallaby/locale.rb
CHANGED
@@ -11,11 +11,11 @@ module Wallaby
|
|
11
11
|
# @return [String] translation
|
12
12
|
def t(key, options = {})
|
13
13
|
translator = options.delete(:translator) || I18n.method(:t)
|
14
|
-
return translator.call(key,
|
14
|
+
return translator.call(key, options) unless key.is_a?(String) || key.is_a?(Symbol)
|
15
15
|
|
16
16
|
new_key, new_defaults = normalize key, options.delete(:default)
|
17
17
|
|
18
|
-
translator.call(new_key,
|
18
|
+
translator.call(new_key, default: new_defaults, **options)
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
@@ -4,16 +4,9 @@ module Wallaby
|
|
4
4
|
# Utils for module and class
|
5
5
|
module ModuleUtils
|
6
6
|
class << self
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
# @param args [Array] a list of arguments
|
11
|
-
# @return [Object] result from executing given method on subject
|
12
|
-
# @return [nil] if subject doesn't respond to given method
|
13
|
-
def try_to(subject, method_id, *args, &block)
|
14
|
-
return if method_id.blank?
|
15
|
-
|
16
|
-
subject.respond_to?(method_id) && subject.public_send(method_id, *args, &block) || nil
|
7
|
+
# @deprecated
|
8
|
+
def try_to(_subject, _method_id, *_args)
|
9
|
+
Deprecator.alert method(__callee__), from: '0.3.0'
|
17
10
|
end
|
18
11
|
|
19
12
|
# Check whether a class is anonymous or not
|
data/lib/utils/wallaby/utils.rb
CHANGED
@@ -1,24 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Wallaby
|
4
|
-
#
|
5
|
-
module Utils
|
6
|
-
# @see http://stackoverflow.com/a/8710663/1326499
|
4
|
+
module Utils # :nodoc:
|
7
5
|
# @param object [Object]
|
8
|
-
# @return [Object] a
|
6
|
+
# @return [Object] a cloned object
|
9
7
|
def self.clone(object)
|
10
|
-
# NOTE: Neither marshal/deep_dup/dup
|
11
|
-
#
|
8
|
+
# NOTE: Neither marshal/deep_dup/dup is able to make a correct deep copy,
|
9
|
+
# therefore, this is our solution:
|
12
10
|
case object
|
13
11
|
when Hash
|
14
|
-
object
|
15
|
-
.each_with_object(object.class.new) { |(key, value), hash| hash[key] = clone(value) }
|
16
|
-
.tap { |hash| hash.default = object.default }
|
12
|
+
HashCloner.execute(object)
|
17
13
|
when Array
|
18
14
|
object.each_with_object(object.class.new) { |value, array| array << clone(value) }
|
19
15
|
when Class
|
20
|
-
# NOTE: `Class.dup`
|
21
|
-
# therefore,
|
16
|
+
# NOTE: `Class.dup` turns the origin Class object into an anonymous clone.
|
17
|
+
# therefore, the Class object itself should be returned instead
|
22
18
|
object
|
23
19
|
else
|
24
20
|
object.dup
|
@@ -28,10 +24,21 @@ module Wallaby
|
|
28
24
|
# @param object [Object, nil]
|
29
25
|
# @return [String] inspection string for the given object
|
30
26
|
def self.inspect(object)
|
31
|
-
return 'nil'
|
32
|
-
return object.
|
27
|
+
return 'nil' if object.nil?
|
28
|
+
return "#{object.class}##{object.try(:id)}" if object.is_a?(::ActiveRecord::Base)
|
29
|
+
|
30
|
+
object.inspect
|
31
|
+
end
|
33
32
|
|
34
|
-
|
33
|
+
# Service object to clone Hash
|
34
|
+
class HashCloner
|
35
|
+
def self.execute(object)
|
36
|
+
# NOTE: `default`/`default_proc` should be cloned as well
|
37
|
+
default_method = object.default_proc ? :default_proc : :default
|
38
|
+
object
|
39
|
+
.each_with_object(object.class.new) { |(key, value), hash| hash[key] = Utils.clone(value) }
|
40
|
+
.tap { |hash| hash.try("#{default_method}=", object.try(default_method)) }
|
41
|
+
end
|
35
42
|
end
|
36
43
|
end
|
37
44
|
end
|
data/lib/wallaby/class_array.rb
CHANGED
@@ -6,11 +6,11 @@ module Wallaby
|
|
6
6
|
include Classifier
|
7
7
|
|
8
8
|
# @param [Array] array
|
9
|
-
def initialize(array
|
10
|
-
@internal = array || []
|
9
|
+
def initialize(*array)
|
10
|
+
@internal = (array || []).flatten
|
11
11
|
return if @internal.blank?
|
12
12
|
|
13
|
-
@internal.map!(
|
13
|
+
@internal.map! { |klass| class_name_of(klass) }.compact!
|
14
14
|
end
|
15
15
|
|
16
16
|
# @!attribute [r] internal
|
@@ -20,13 +20,13 @@ module Wallaby
|
|
20
20
|
# @!attribute [r] origin
|
21
21
|
# @return [Array] The original array.
|
22
22
|
def origin
|
23
|
-
# NOTE: DO NOT cache it
|
24
|
-
@internal.map(
|
23
|
+
# NOTE: DO NOT cache it using instance variable!
|
24
|
+
@internal.map { |klass| to_class(klass) }.compact
|
25
25
|
end
|
26
26
|
|
27
27
|
# Save the value to the {#internal} array at the given index, and convert the Class value to String
|
28
28
|
def []=(index, value)
|
29
|
-
@internal[index] =
|
29
|
+
@internal[index] = class_name_of value
|
30
30
|
end
|
31
31
|
|
32
32
|
# Return the value for the given index
|
@@ -35,18 +35,19 @@ module Wallaby
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# @param other [Array]
|
38
|
-
# @return [
|
38
|
+
# @return [ClassArray] new Class array
|
39
39
|
def concat(other)
|
40
40
|
self.class.new origin.concat(other.try(:origin) || other)
|
41
41
|
end
|
42
42
|
|
43
|
-
# @param
|
44
|
-
# @return [
|
45
|
-
def
|
46
|
-
|
43
|
+
# @param item [Class, String]
|
44
|
+
# @return [ClassArray] self
|
45
|
+
def <<(item)
|
46
|
+
@internal << class_name_of(item)
|
47
|
+
self
|
47
48
|
end
|
48
49
|
|
49
|
-
# @return [
|
50
|
+
# @return [ClassArray] self
|
50
51
|
def each(&block)
|
51
52
|
origin.each(&block)
|
52
53
|
self
|
@@ -56,6 +57,10 @@ module Wallaby
|
|
56
57
|
# Compare #{origin} with other.
|
57
58
|
delegate :==, to: :origin
|
58
59
|
|
60
|
+
# @!method to_a
|
61
|
+
# Get the array of #{origin}.
|
62
|
+
delegate :to_a, to: :origin
|
63
|
+
|
59
64
|
# @!method blank?
|
60
65
|
delegate :blank?, to: :internal
|
61
66
|
|
@@ -66,7 +71,7 @@ module Wallaby
|
|
66
71
|
delegate :to_sentence, to: :origin
|
67
72
|
|
68
73
|
# Ensure to freeze the {#internal}
|
69
|
-
# @return [
|
74
|
+
# @return [ClassArray] self
|
70
75
|
def freeze
|
71
76
|
@internal.freeze
|
72
77
|
super
|
data/lib/wallaby/class_hash.rb
CHANGED
@@ -4,7 +4,7 @@ module Wallaby
|
|
4
4
|
# This is a constant-safe hash that stores Class key/value as String
|
5
5
|
# and returns value as Class if it was a Class.
|
6
6
|
#
|
7
|
-
# It can be used for global methods (e.g. {
|
7
|
+
# It can be used for global methods (e.g. {Map.mode_map}) which cache the computed result,
|
8
8
|
# so that when Rails reloads, it won't complain that old Class constants still exist in
|
9
9
|
# ObjectSpace (see https://github.com/wallaby-rails/wallaby/issues/181).
|
10
10
|
#
|
@@ -22,8 +22,8 @@ module Wallaby
|
|
22
22
|
def initialize(hash = {})
|
23
23
|
@internal =
|
24
24
|
(hash || {})
|
25
|
-
.transform_keys(
|
26
|
-
.transform_values(
|
25
|
+
.transform_keys { |klass| class_name_of(klass) }
|
26
|
+
.transform_values { |klass| class_name_of(klass) }
|
27
27
|
end
|
28
28
|
|
29
29
|
# @!attribute [r] origin
|
@@ -31,11 +31,15 @@ module Wallaby
|
|
31
31
|
def origin
|
32
32
|
# NOTE: DO NOT cache it by using instance variable!
|
33
33
|
@internal
|
34
|
-
.transform_keys(
|
35
|
-
.transform_values(
|
34
|
+
.transform_keys { |klass| to_class(klass) }
|
35
|
+
.transform_values { |klass| to_class(klass) }
|
36
36
|
.reject { |k, v| k.nil? || v.nil? }
|
37
37
|
end
|
38
38
|
|
39
|
+
# @!method key?
|
40
|
+
# Return if {#origin} has the given key.
|
41
|
+
delegate :key?, to: :origin
|
42
|
+
|
39
43
|
# @!method keys
|
40
44
|
# Return the keys of {#origin}.
|
41
45
|
delegate :keys, to: :origin
|
@@ -50,27 +54,27 @@ module Wallaby
|
|
50
54
|
|
51
55
|
# Save the key/value to the {#internal} hash, and convert the Class key/value to String
|
52
56
|
def []=(key, value)
|
53
|
-
@internal[
|
57
|
+
@internal[class_name_of(key)] = class_name_of(value)
|
54
58
|
end
|
55
59
|
|
56
60
|
# Return the value for the given key, and convert the value back to Class if it was a Class
|
57
61
|
def [](key)
|
58
|
-
to_class @internal[
|
62
|
+
to_class @internal[class_name_of(key)]
|
59
63
|
end
|
60
64
|
|
61
65
|
# @param other [Hash]
|
62
|
-
# @return [
|
66
|
+
# @return [ClassHash] new Class hash
|
63
67
|
def merge(other)
|
64
68
|
self.class.new origin.merge(other.try(:origin) || other)
|
65
69
|
end
|
66
70
|
|
67
|
-
# @return [
|
71
|
+
# @return [ClassHash] new Class hash
|
68
72
|
def select(&block)
|
69
73
|
self.class.new origin.select(&block)
|
70
74
|
end
|
71
75
|
|
72
76
|
# Ensure to freeze the {#internal}
|
73
|
-
# @return [
|
77
|
+
# @return [ClassHash] self
|
74
78
|
def freeze
|
75
79
|
@internal.freeze
|
76
80
|
super
|
@@ -79,16 +83,14 @@ module Wallaby
|
|
79
83
|
protected
|
80
84
|
|
81
85
|
# Convert to Class name
|
82
|
-
def
|
86
|
+
def class_name_of(klass)
|
83
87
|
klass.is_a?(Class) ? [klass.name, true] : [klass, false]
|
84
88
|
end
|
85
89
|
|
86
90
|
# Convert to Class
|
87
91
|
def to_class(pair)
|
88
92
|
val, is_class = pair
|
89
|
-
is_class ? val
|
90
|
-
rescue NameError
|
91
|
-
Logger.error "`#{val}` is not a valid Class name."
|
93
|
+
is_class ? Classifier.to_class(val) : val
|
92
94
|
end
|
93
95
|
end
|
94
96
|
end
|
data/lib/wallaby/classifier.rb
CHANGED
@@ -3,11 +3,13 @@
|
|
3
3
|
module Wallaby
|
4
4
|
# Concern to handle the conversion between Class and String
|
5
5
|
module Classifier
|
6
|
+
extend self
|
7
|
+
|
6
8
|
# Convert Class to String. If not Class, unchanged.
|
7
9
|
# @param klass [Object]
|
8
10
|
# @return [String] if klass is a Class
|
9
11
|
# @return [Object] if klass is not a Class
|
10
|
-
def
|
12
|
+
def class_name_of(klass)
|
11
13
|
klass.try(:name) || klass || nil
|
12
14
|
end
|
13
15
|
|
@@ -23,7 +25,7 @@ module Wallaby
|
|
23
25
|
# This is Rails, use constantize
|
24
26
|
name.constantize
|
25
27
|
rescue NameError
|
26
|
-
|
28
|
+
yield(name) if block_given?
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
@@ -5,7 +5,9 @@ module Wallaby
|
|
5
5
|
# Features global configuration
|
6
6
|
class Features
|
7
7
|
# @!attribute [w] turbolinks_enabled
|
8
|
-
|
8
|
+
def turbolinks_enabled=(_turbolinks_enabled)
|
9
|
+
Deprecator.alert 'config.features.turbolinks_enabled=', from: '0.3.0'
|
10
|
+
end
|
9
11
|
|
10
12
|
# @!attribute [r] turbolinks_enabled
|
11
13
|
# To globally configure whether to use turbolinks or not.
|
@@ -17,7 +19,11 @@ module Wallaby
|
|
17
19
|
# end
|
18
20
|
# @return [Boolean] a feture flag of turbolinks, default to false.
|
19
21
|
def turbolinks_enabled
|
20
|
-
|
22
|
+
Deprecator.alert method(__callee__), from: '0.3.0', alternative: <<~INSTRUCTION
|
23
|
+
If Turbolinks is included, it will be used by Wallaby. If you want to disable it,
|
24
|
+
you can either take `turbolinks` gem out from your Gemfile
|
25
|
+
or override the `frontend` partial by taking it out.
|
26
|
+
INSTRUCTION
|
21
27
|
end
|
22
28
|
end
|
23
29
|
end
|
@@ -2,144 +2,98 @@
|
|
2
2
|
|
3
3
|
module Wallaby
|
4
4
|
class Configuration
|
5
|
-
#
|
6
|
-
# @since wallaby-5.1.6
|
5
|
+
# @deprecated
|
7
6
|
class Mapping
|
8
7
|
include Classifier
|
9
8
|
|
10
|
-
#
|
11
|
-
def resources_controller=(
|
12
|
-
|
9
|
+
# @deprecated
|
10
|
+
def resources_controller=(_resources_controller)
|
11
|
+
Deprecator.alert 'config.mapping.resources_controller=', from: '0.3.0', alternative: <<~INSTRUCTION
|
12
|
+
Please set #resources_controller= from the config instead, for example:
|
13
|
+
|
14
|
+
Wallaby.config do |config|
|
15
|
+
config.resources_controller = ::GlobalResourcesController
|
16
|
+
end
|
17
|
+
INSTRUCTION
|
13
18
|
end
|
14
19
|
|
15
|
-
#
|
16
|
-
# To globally configure the resources controller.
|
17
|
-
#
|
18
|
-
# If no configuration is given, Wallaby will look up from the following controller classes
|
19
|
-
# and use the first available one:
|
20
|
-
#
|
21
|
-
# - ::Admin::ApplicationController (only when it inherits from {Wallaby::ResourcesController})
|
22
|
-
# - {Wallaby::ResourcesController}
|
23
|
-
# @example To update the resources controller to `GlobalResourcesController` in `config/initializers/wallaby.rb`
|
24
|
-
# Wallaby.config do |config|
|
25
|
-
# config.mapping.resources_controller = ::GlobalResourcesController
|
26
|
-
# end
|
27
|
-
# @return [Class] resources controller class
|
28
|
-
# @since wallaby-5.1.6
|
20
|
+
# @deprecated
|
29
21
|
def resources_controller
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
&& 'Admin::ApplicationController'
|
34
|
-
to_class @resources_controller ||= 'Wallaby::ResourcesController'
|
22
|
+
Deprecator.alert 'config.mapping.resources_controller', from: '0.3.0', alternative: <<~INSTRUCTION
|
23
|
+
Please use config.resources_controller instead.
|
24
|
+
INSTRUCTION
|
35
25
|
end
|
36
26
|
|
37
|
-
#
|
38
|
-
def resource_decorator=(
|
39
|
-
|
27
|
+
# @deprecated
|
28
|
+
def resource_decorator=(_resource_decorator)
|
29
|
+
Deprecator.alert 'config.mapping.resource_decorator=', from: '0.3.0', alternative: <<~INSTRUCTION
|
30
|
+
Please set .application_decorator= from the controller instead, for example:
|
31
|
+
|
32
|
+
class Admin::ApplicationController < Wallaby::ResourcesController
|
33
|
+
self.application_decorator = ::GlobalModelDecorator
|
34
|
+
end
|
35
|
+
INSTRUCTION
|
40
36
|
end
|
41
37
|
|
42
|
-
#
|
43
|
-
# To globally configure the resource decorator.
|
44
|
-
#
|
45
|
-
# If no configuration is given, Wallaby will look up from the following decorator classes
|
46
|
-
# and use the first available one:
|
47
|
-
#
|
48
|
-
# - ::Admin::ApplicationDecorator (only when it inherits from {Wallaby::ResourceDecorator})
|
49
|
-
# - {Wallaby::ResourceDecorator}
|
50
|
-
# @example To update the resource decorator to `GlobalResourceDecorator` in `config/initializers/wallaby.rb`
|
51
|
-
# Wallaby.config do |config|
|
52
|
-
# config.mapping.resource_decorator = ::GlobalResourceDecorator
|
53
|
-
# end
|
54
|
-
# @return [Class] resource decorator class
|
55
|
-
# @since wallaby-5.1.6
|
38
|
+
# @deprecated
|
56
39
|
def resource_decorator
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
&& 'Admin::ApplicationDecorator'
|
61
|
-
to_class @resource_decorator ||= 'Wallaby::ResourceDecorator'
|
40
|
+
Deprecator.alert 'config.mapping.resource_decorator', from: '0.3.0', alternative: <<~INSTRUCTION
|
41
|
+
Please use controller_class.application_decorator.
|
42
|
+
INSTRUCTION
|
62
43
|
end
|
63
44
|
|
64
|
-
#
|
65
|
-
def model_servicer=(
|
66
|
-
|
45
|
+
# @deprecated
|
46
|
+
def model_servicer=(_model_servicer)
|
47
|
+
Deprecator.alert 'config.mapping.model_servicer=', from: '0.3.0', alternative: <<~INSTRUCTION
|
48
|
+
Please set .application_servicer= from the controller instead, for example:
|
49
|
+
|
50
|
+
class Admin::ApplicationController < Wallaby::ResourcesController
|
51
|
+
self.application_servicer = ::GlobalModelServicer
|
52
|
+
end
|
53
|
+
INSTRUCTION
|
67
54
|
end
|
68
55
|
|
69
|
-
#
|
70
|
-
# To globally configure the model servicer.
|
71
|
-
#
|
72
|
-
# If no configuration is given, Wallaby will look up from the following servicer classes
|
73
|
-
# and use the first available one:
|
74
|
-
#
|
75
|
-
# - ::Admin::ApplicationServicer (only when it inherits from {Wallaby::ModelServicer})
|
76
|
-
# - {Wallaby::ModelServicer}
|
77
|
-
# @example To update the model servicer to `GlobalModelServicer` in `config/initializers/wallaby.rb`
|
78
|
-
# Wallaby.config do |config|
|
79
|
-
# config.mapping.model_servicer = ::GlobalModelServicer
|
80
|
-
# end
|
81
|
-
# @return [Class] model servicer class
|
82
|
-
# @since wallaby-5.1.6
|
56
|
+
# @deprecated
|
83
57
|
def model_servicer
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
&& 'Admin::ApplicationServicer'
|
88
|
-
to_class @model_servicer ||= 'Wallaby::ModelServicer'
|
58
|
+
Deprecator.alert 'config.mapping.model_servicer', from: '0.3.0', alternative: <<~INSTRUCTION
|
59
|
+
Please use controller_class.application_servicer.
|
60
|
+
INSTRUCTION
|
89
61
|
end
|
90
62
|
|
91
|
-
#
|
92
|
-
def model_authorizer=(
|
93
|
-
|
63
|
+
# @deprecated
|
64
|
+
def model_authorizer=(_model_authorizer)
|
65
|
+
Deprecator.alert 'config.mapping.model_authorizer=', from: '0.3.0', alternative: <<~INSTRUCTION
|
66
|
+
Please set .application_authorizer= from the controller instead, for example:
|
67
|
+
|
68
|
+
class Admin::ApplicationController < Wallaby::ResourcesController
|
69
|
+
self.application_authorizer = ::GlobalModelAuthorizer
|
70
|
+
end
|
71
|
+
INSTRUCTION
|
94
72
|
end
|
95
73
|
|
96
|
-
#
|
97
|
-
# To globally configure the model authorizer.
|
98
|
-
#
|
99
|
-
# If no configuration is given, Wallaby will look up from the following authorizer classes
|
100
|
-
# and use the first available one:
|
101
|
-
#
|
102
|
-
# - ::Admin::ApplicationAuthorizer (only when it inherits from {Wallaby::ModelAuthorizer})
|
103
|
-
# - {Wallaby::ModelAuthorizer}
|
104
|
-
# @example To update the model authorizer to `GlobalModelAuthorizer` in `config/initializers/wallaby.rb`
|
105
|
-
# Wallaby.config do |config|
|
106
|
-
# config.mapping.model_authorizer = ::GlobalModelAuthorizer
|
107
|
-
# end
|
108
|
-
# @return [Class] model authorizer class
|
109
|
-
# @since wallaby-5.2.0
|
74
|
+
# @deprecated
|
110
75
|
def model_authorizer
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
&& 'Admin::ApplicationAuthorizer'
|
115
|
-
to_class @model_authorizer ||= 'Wallaby::ModelAuthorizer'
|
76
|
+
Deprecator.alert 'config.mapping.model_authorizer', from: '0.3.0', alternative: <<~INSTRUCTION
|
77
|
+
Please use controller_class.application_authorizer.
|
78
|
+
INSTRUCTION
|
116
79
|
end
|
117
80
|
|
118
|
-
#
|
119
|
-
def model_paginator=(
|
120
|
-
|
81
|
+
# @deprecated
|
82
|
+
def model_paginator=(_model_paginator)
|
83
|
+
Deprecator.alert 'config.mapping.model_paginator=', from: '0.3.0', alternative: <<~INSTRUCTION
|
84
|
+
Please set .application_paginator= from the controller instead, for example:
|
85
|
+
|
86
|
+
class Admin::ApplicationController < Wallaby::ResourcesController
|
87
|
+
self.application_paginator = ::GlobalModelPaginator
|
88
|
+
end
|
89
|
+
INSTRUCTION
|
121
90
|
end
|
122
91
|
|
123
|
-
#
|
124
|
-
# To globally configure the resource paginator.
|
125
|
-
#
|
126
|
-
# If no configuration is given, Wallaby will look up from the following paginator classes
|
127
|
-
# and use the first available one:
|
128
|
-
#
|
129
|
-
# - ::Admin::ApplicationPaginator (only when it inherits from {Wallaby::ModelPaginator})
|
130
|
-
# - {Wallaby::ModelPaginator}
|
131
|
-
# @example To update the resource paginator to `GlobalModelPaginator` in `config/initializers/wallaby.rb`
|
132
|
-
# Wallaby.config do |config|
|
133
|
-
# config.mapping.model_paginator = ::GlobalModelPaginator
|
134
|
-
# end
|
135
|
-
# @return [Class] resource paginator class
|
136
|
-
# @since wallaby-5.2.0
|
92
|
+
# @deprecated
|
137
93
|
def model_paginator
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
&& 'Admin::ApplicationPaginator'
|
142
|
-
to_class @model_paginator ||= 'Wallaby::ModelPaginator'
|
94
|
+
Deprecator.alert 'config.mapping.model_paginator', from: '0.3.0', alternative: <<~INSTRUCTION
|
95
|
+
Please use controller_class.application_paginator.
|
96
|
+
INSTRUCTION
|
143
97
|
end
|
144
98
|
end
|
145
99
|
end
|
@@ -2,21 +2,24 @@
|
|
2
2
|
|
3
3
|
module Wallaby
|
4
4
|
class Configuration
|
5
|
-
#
|
5
|
+
# @deprecated
|
6
6
|
class Metadata
|
7
|
-
#
|
8
|
-
|
7
|
+
# @deprecated
|
8
|
+
def max=(_max)
|
9
|
+
Deprecator.alert 'config.metadata.max=', from: '0.3.0', alternative: <<~INSTRUCTION
|
10
|
+
Please set .max_text_length= from the controller instead, for example:
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
# @
|
17
|
-
# @since wallaby-5.1.6
|
12
|
+
class Admin::ApplicationController < Wallaby::ResourcesController
|
13
|
+
self.max_text_length = 50
|
14
|
+
end
|
15
|
+
INSTRUCTION
|
16
|
+
end
|
17
|
+
|
18
|
+
# @deprecated
|
18
19
|
def max
|
19
|
-
|
20
|
+
Deprecator.alert 'config.metadata.max', from: '0.3.0', alternative: <<~INSTRUCTION
|
21
|
+
Please use controller_class.max_text_length instead.
|
22
|
+
INSTRUCTION
|
20
23
|
end
|
21
24
|
end
|
22
25
|
end
|
@@ -2,40 +2,42 @@
|
|
2
2
|
|
3
3
|
module Wallaby
|
4
4
|
class Configuration
|
5
|
-
# @deprecated
|
6
|
-
# Models configuration to specify the model classes that Wallaby should handle.
|
5
|
+
# @deprecated
|
7
6
|
class Models
|
8
|
-
# @
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
# @deprecated
|
8
|
+
def set(*_models)
|
9
|
+
Deprecator.alert 'config.models.set', from: '0.3.0', alternative: <<~INSTRUCTION
|
10
|
+
Please set #models= from the controller instead, for example:
|
11
|
+
|
12
|
+
class Admin::ApplicationController < Wallaby::ResourcesController
|
13
|
+
self.models = User, 'Product'
|
14
|
+
end
|
15
|
+
INSTRUCTION
|
17
16
|
end
|
18
17
|
|
19
|
-
# @
|
18
|
+
# @deprecated
|
20
19
|
def presence
|
21
|
-
|
20
|
+
Deprecator.alert 'config.models.presence', from: '0.3.0', alternative: <<~INSTRUCTION
|
21
|
+
Please use controller_class.models instead.
|
22
|
+
INSTRUCTION
|
22
23
|
end
|
23
24
|
|
24
|
-
# @
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
# @deprecated
|
26
|
+
def exclude(*_models)
|
27
|
+
Deprecator.alert 'config.models.exclude', from: '0.3.0', alternative: <<~INSTRUCTION
|
28
|
+
Please set #models_to_exclude from the controller instead, for example:
|
29
|
+
|
30
|
+
class Admin::ApplicationController < Wallaby::ResourcesController
|
31
|
+
self.models_to_exclude User, 'Product'
|
32
|
+
end
|
33
|
+
INSTRUCTION
|
33
34
|
end
|
34
35
|
|
35
|
-
# @
|
36
|
-
# By default, `ActiveRecord::SchemaMigration` is excluded.
|
36
|
+
# @deprecated
|
37
37
|
def excludes
|
38
|
-
|
38
|
+
Deprecator.alert 'config.models.excludes', from: '0.3.0', alternative: <<~INSTRUCTION
|
39
|
+
Please use controller_class.models_to_exclude instead.
|
40
|
+
INSTRUCTION
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|