use crate::modelo::{{ pascal }};
use crate::modelo::Props{{ pascal }};{% for import in imports %}
use {{ import }};{% endfor %}
pub struct Madre{{ pascal }} {
{% for f in fields %} {{ f.name }}: Option<{{ f.mother_storage }}>,
{% endfor %}}
impl Madre{{ pascal }} {
pub fn new() -> Self {
Self { {% for f in fields %}{{ f.name }}: None{% if not loop.last %}, {% endif %}{% endfor %} }
}
{% for f in fields %}
pub fn con_{{ f.name }}(mut self, {{ f.name }}: {{ f.mother_param }}) -> Self {
self.{{ f.name }} = Some({{ f.name }}{% if f.mother_param == "&str" %}.to_string(){% endif %});
self
}
{% endfor %}{% for f in fields | filter(attribute="required_string", value=true) %}
pub fn con_{{ f.name }}_vacio(mut self) -> Self {
self.{{ f.name }} = Some(String::new());
self
}
{% endfor %}
pub fn construir(self) -> {{ pascal }} {
{{ pascal }}::new(Props{{ pascal }} {
{% for f in fields %} {{ f.name }}: {{ f.mother_build }},
{% endfor %} })
.expect("Madre{{ pascal }}: {{ pascal }}::new rechazó los props")
}
pub fn construir_props(self) -> Props{{ pascal }} {
Props{{ pascal }} {
{% for f in fields %} {{ f.name }}: {{ f.mother_build }},
{% endfor %} }
}
pub fn aleatorio() -> {{ pascal }} {
Self::new().construir()
}
pub fn aleatorios(n: usize) -> Vec<{{ pascal }}> {
(0..n).map(|_| Self::aleatorio()).collect()
}
}
impl Default for Madre{{ pascal }} {
fn default() -> Self {
Self::new()
}
}