Add documentation to customize other Ruby classes

This commit is contained in:
Javi Martín
2024-08-30 16:10:27 +02:00
parent 19e12d9053
commit 58a5b7e627
6 changed files with 64 additions and 0 deletions

View File

@@ -37,6 +37,7 @@
* [Controllers](customization/controllers.md)
* [Views and HTML](customization/views.md)
* [Components](customization/components.md)
* [Other Ruby classes (GraphQL, lib, mailers, builders)](customization/ruby.md)
* [Gems](customization/gems.md)
* [Application configuration](customization/application.md)

View File

@@ -9,5 +9,6 @@
* [Controllers](controllers.md)
* [Views and HTML](views.md)
* [Components](components.md)
* [Other Ruby classes (GraphQL, lib, mailers, builders)](ruby.md)
* [Gems](gems.md)
* [Application configuration](application.md)

View File

@@ -0,0 +1,30 @@
# Customizing other Ruby classes
Other than models, controllers and components, there are a few other folders containing Ruby code:
* `app/form_builders/`
* `app/graphql/`
* `app/lib/`
* `app/mailers/`
The files in these folders can be customized like any other Ruby file (see [customizing models](models.md) for more information).
For example, in order to customize the `app/form_builders/consul_form_builder.rb` file, create a file `app/form_builders/custom/consul_form_builder.rb` with the following content:
```ruby
load Rails.root.join("app", "form_builders", "consul_form_builder.rb")
class ConsulFormBuilder
# Your custom logic here
end
```
Or, in order to customize the `app/lib/remote_translations/caller.rb` file, create a file `app/lib/custom/remote_translations/caller.rb` with the following content:
```ruby
load Rails.root.join("app", "lib", "remote_translations", "caller.rb")
class RemoteTranslations::Caller
# Your custom logic here
end
```

View File

@@ -37,6 +37,7 @@
* [Controladores](customization/controllers.md)
* [Vistas y HTML](customization/views.md)
* [Componentes](customization/components.md)
* [Otras clases de Ruby (GraphQL, lib, mailers, builders)](customization/ruby.md)
* [Gemas](customization/gems.md)
* [Configuración de la aplicación](customization/application.md)

View File

@@ -9,5 +9,6 @@
* [Controladores](controllers.md)
* [Vistas y HTML](views.md)
* [Componentes](components.md)
* [Otras clases de Ruby (GraphQL, lib, mailers, builders)](ruby.md)
* [Gemas](gems.md)
* [Configuración de la aplicación](application.md)

View File

@@ -0,0 +1,30 @@
# Personalización de otras clases de Ruby
Aparte de modelos, controladores y componentes, hay otros directorios que contienen código de Ruby:
* `app/form_builders/`
* `app/graphql/`
* `app/lib/`
* `app/mailers/`
Los ficheros en estos directorios pueden personalizarse como cualquier otro fichero de Ruby (véase [personalización de modelos](models.md) para más información).
Por ejemplo, para personalizar el fichero `app/form_builders/consul_form_builder.rb`, crea el archivo `app/form_builders/custom/consul_form_builder.rb` con el siguiente contenido:
```ruby
load Rails.root.join("app", "form_builders", "consul_form_builder.rb")
class ConsulFormBuilder
# Your custom logic here
end
```
O, para personalizar el fichero `app/lib/remote_translations/caller.rb`, crea el archivo `app/lib/custom/remote_translations/caller.rb` con el siguiente contenido:
```ruby
load Rails.root.join("app", "lib", "remote_translations", "caller.rb")
class RemoteTranslations::Caller
# Your custom logic here
end
```