add copyWithout method to classes

This commit is contained in:
Ivan Smolin 2018-10-30 15:37:32 +03:00
parent 7c24039a3d
commit 81163c14b3
3 changed files with 18 additions and 0 deletions

View File

@ -83,6 +83,10 @@ extension {{ type.baseTypeName }} {
return {{ type.baseTypeName }}({%- include 'blocks/class/fields-optional-initialization.twig' with { fields: allFieldsOrdered } -%})
}
func copy{%- if hasChilds -%}{{ type.baseTypeName }}{%- endif -%}Without({%- include 'blocks/class/bool-parameters-fields.twig' with { fields: allFieldsOrdered } -%}) -> {{ type.baseTypeName }} {
return {{ type.baseTypeName }}({%- include 'blocks/class/fields-without-initialization.twig' with { fields: allFieldsOrdered } -%})
}
}
{{ "\n" }}
{%- endif -%}

View File

@ -0,0 +1,7 @@
{%- import '../../macroses/common.utils.twig' as utils -%}
{%- if fields is not empty -%}
{%- for field in fields -%}
{{ field.name }}: Bool = false{%- if not (loop.last) %}, {% endif %}
{%- endfor -%}
{%- endif -%}

View File

@ -0,0 +1,7 @@
{%- import '../../macroses/common.utils.twig' as utils -%}
{%- if fields is not empty -%}
{%- for field in fields -%}
{{ field.name }}: {{ field.name }} ? {{ utils.defaultValueForField(field) }} : self.{{ field.name }}{%- if not (loop.last) %}, {% endif %}
{%- endfor -%}
{%- endif -%}