# Ejemplo: Módulo para variables de entorno

```ruby
# lib/my_module.rb
module MyModule
  MY_NUMBER = ENV.fetch("MY_NUMBER", 10)
  MY_BOOLEAN = ENV["MY_BOOLEAN"]

  def self.my_number
    MY_NUMBER.to_i
  end

  def self.my_boolean?
    MY_BOOLEAN == "true"
  end
end

# se acceden así: 
MyModule.my_number
	MyModule.my_boolean?
```

Definimos un módulo en donde los fetch de las variables de entorno están fuera de los métodos (de esta manera si una variable de entorno no está definida fallará el build). Dentro de los métodos sólo se encuentra el formateo de las variables

Para que el módulo esté disponible en la aplicación, se debe agregar el require en el archivo `application.rb`

```ruby
# application.rb
config.before_configuration do
   require Rails.root.join("lib/my_module.rb")
end
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://la-guia.platan.us/acuerdos/guia_de_estilo/ejemplo_modulo_para_variables_de_entorno.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
