Module: Wallaby::Configurable::ClassMethods
- Defined in:
- lib/concerns/wallaby/configurable.rb,
lib/concerns/wallaby/configurable.rb,
lib/concerns/wallaby/configurable.rb,
lib/concerns/wallaby/configurable.rb,
lib/concerns/wallaby/configurable.rb,
lib/concerns/wallaby/configurable.rb,
lib/concerns/wallaby/configurable.rb,
lib/concerns/wallaby/configurable.rb,
lib/concerns/wallaby/configurable.rb,
lib/concerns/wallaby/configurable.rb,
lib/concerns/wallaby/configurable.rb,
lib/concerns/wallaby/configurable.rb
Overview
Clear configurables
Instance Attribute Summary collapse
-
#application_authorizer ⇒ Class
It is the base class of #model_authorizer.
-
#application_controller ⇒ Class
readonly
Application controller class.
-
#application_decorator ⇒ Class
It is the base class of #resource_decorator.
-
#application_paginator ⇒ Class
It is the base class of #model_paginator.
-
#application_servicer ⇒ Class
It is the base class of #model_servicer.
-
#email_method ⇒ Object
To configure the method on AuthenticationConcern#wallaby_user to retrieve email address.
-
#engine_name ⇒ String, ...
It is used to help with URLs handling (see Engine).
-
#logout_method ⇒ Object
To configure the logout HTTP method.
-
#logout_path ⇒ Object
To configure the logout path.
-
#max_text_length ⇒ Integer
To configure max number of characters to truncate for each text field on index page.
-
#model_authorizer ⇒ Class
Model authorizer.
-
#model_paginator ⇒ Class
Model paginator.
-
#model_servicer ⇒ Class
Model servicer.
-
#models ⇒ Object
To configure the models that the controller should be handling.
-
#models_to_exclude ⇒ Object
To configure the models to exclude that the controller should be handling.
-
#page_size ⇒ Integer
To configure the page size for pagination on index page.
-
#resource_decorator ⇒ Class
Resource decorator.
-
#sorting_strategy ⇒ Integer
To configure which strategy to use for sorting on index page.
Instance Method Summary collapse
-
#all_models ⇒ Array<Class>
All models.
-
#clear ⇒ Object
Clear all configurations.
Instance Attribute Details
#application_authorizer ⇒ Class
It is the base class of #model_authorizer.
139 140 141 142 |
# File 'lib/concerns/wallaby/configurable.rb', line 139 def @application_authorizer ||= Guesser.class_for(name, suffix: AUTHORIZER, &:base_class?) @application_authorizer || superclass.try(:application_authorizer) || ModelAuthorizer end |
#application_controller ⇒ Class (readonly)
Returns application controller class.
33 34 35 36 37 |
# File 'lib/concerns/wallaby/configurable.rb', line 33 def application_controller return self if base_class? superclass.try(:application_controller) || ResourcesController end |
#application_decorator ⇒ Class
It is the base class of #resource_decorator.
69 70 71 72 |
# File 'lib/concerns/wallaby/configurable.rb', line 69 def application_decorator @application_decorator ||= Guesser.class_for(name, suffix: DECORATOR, &:base_class?) @application_decorator || superclass.try(:application_decorator) || ResourceDecorator end |
#application_paginator ⇒ Class
It is the base class of #model_paginator.
174 175 176 177 |
# File 'lib/concerns/wallaby/configurable.rb', line 174 def application_paginator @application_paginator ||= Guesser.class_for(name, suffix: PAGINATOR, &:base_class?) @application_paginator || superclass.try(:application_paginator) || ModelPaginator end |
#application_servicer ⇒ Class
It is the base class of #model_servicer.
104 105 106 107 |
# File 'lib/concerns/wallaby/configurable.rb', line 104 def application_servicer @application_servicer ||= Guesser.class_for(name, suffix: SERVICER, &:base_class?) @application_servicer || superclass.try(:application_servicer) || ModelServicer end |
#email_method ⇒ Object
To configure the method on AuthenticationConcern#wallaby_user to retrieve email address.
If no configuration is given, it will attempt to call ‘email` on AuthenticationConcern#wallaby_user.
297 298 299 |
# File 'lib/concerns/wallaby/configurable.rb', line 297 def email_method @email_method || superclass.try(:email_method) end |
#engine_name ⇒ String, ...
24 25 26 |
# File 'lib/concerns/wallaby/configurable.rb', line 24 def engine_name @engine_name || superclass.try(:engine_name) end |
#logout_method ⇒ Object
To configure the logout HTTP method.
Wallaby does not implement any authentication (e.g. login/logout), therefore, logout method will be required so that Wallaby knows how navigate the user via what HTTP method when user clicks the logout button.
But once it detects ‘Devise`, it will use the HTTP method that Devise uses without the need of configuration.
269 270 271 |
# File 'lib/concerns/wallaby/configurable.rb', line 269 def logout_method @logout_method || superclass.try(:logout_method) end |
#logout_path ⇒ Object
To configure the logout path.
Wallaby does not implement any authentication (e.g. login/logout), therefore, logout path will be required so that Wallaby knows where to navigate the user to when user clicks the logout button.
But once it detects ‘Devise`, it will use the path that Devise uses without the need of configuration.
243 244 245 |
# File 'lib/concerns/wallaby/configurable.rb', line 243 def logout_path @logout_path || superclass.try(:logout_path) end |
#max_text_length ⇒ Integer
To configure max number of characters to truncate for each text field on index page.
323 324 325 |
# File 'lib/concerns/wallaby/configurable.rb', line 323 def max_text_length @max_text_length || superclass.try(:max_text_length) || DEFAULT_MAX end |
#model_authorizer ⇒ Class
Returns model authorizer.
123 124 125 |
# File 'lib/concerns/wallaby/configurable.rb', line 123 def @model_authorizer ||= Guesser.class_for(name, suffix: AUTHORIZER, &:model_class) end |
#model_paginator ⇒ Class
Returns model paginator.
158 159 160 |
# File 'lib/concerns/wallaby/configurable.rb', line 158 def model_paginator @model_paginator ||= Guesser.class_for(name, suffix: PAGINATOR, &:model_class) end |
#model_servicer ⇒ Class
Returns model servicer.
88 89 90 |
# File 'lib/concerns/wallaby/configurable.rb', line 88 def model_servicer @model_servicer ||= Guesser.class_for(name, suffix: SERVICER, &:model_class) end |
#models ⇒ Object
To configure the models that the controller should be handling. It takes both Class and Class String.
190 191 192 |
# File 'lib/concerns/wallaby/configurable.rb', line 190 def models @models || superclass.try(:models) || ClassArray.new end |
#models_to_exclude ⇒ Object
If models are allowlisted using #models, models exclusion will NOT be applied.
To configure the models to exclude that the controller should be handling. It takes both Class and Class String.
208 209 210 211 212 |
# File 'lib/concerns/wallaby/configurable.rb', line 208 def models_to_exclude @models_to_exclude || superclass.try(:models_to_exclude) || DefaultModelsExcluder.execute end |
#page_size ⇒ Integer
To configure the page size for pagination on index page.
Page size can be one of the following values:
-
10
-
20
-
50
-
100
357 358 359 |
# File 'lib/concerns/wallaby/configurable.rb', line 357 def page_size @page_size || superclass.try(:page_size) || DEFAULT_PAGE_SIZE end |
#resource_decorator ⇒ Class
Returns resource decorator.
53 54 55 |
# File 'lib/concerns/wallaby/configurable.rb', line 53 def resource_decorator @resource_decorator ||= Guesser.class_for(name, suffix: DECORATOR, &:model_class) end |
#sorting_strategy ⇒ Integer
To configure which strategy to use for sorting on index page. Options are
- `:multiple`: support multiple columns sorting
- `:single`: support single column sorting
386 387 388 |
# File 'lib/concerns/wallaby/configurable.rb', line 386 def sorting_strategy @sorting_strategy || superclass.try(:sorting_strategy) || :multiple end |
Instance Method Details
#all_models ⇒ Array<Class>
Returns all models.
220 221 222 223 224 225 226 |
# File 'lib/concerns/wallaby/configurable.rb', line 220 def all_models ModelClassFilter.execute( all: Map.mode_map.keys, allowlisted: models.origin, denylisted: models_to_exclude.origin ) end |
#clear ⇒ Object
Clear all configurations
404 405 406 407 408 |
# File 'lib/concerns/wallaby/configurable.rb', line 404 def clear ClassMethods.instance_methods.grep(/=/).each do |name| instance_variable_set :"@#{name[0...-1]}", nil end end |