From 1bf5694e6b830a22b2a9f1096ae32a7646d7d5ed Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Mon, 2 Apr 2018 17:45:54 +0300 Subject: [PATCH] fix singleton and empty date formats --- Swift/ApiDateFormattingService.swift.twig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Swift/ApiDateFormattingService.swift.twig b/Swift/ApiDateFormattingService.swift.twig index 77da2ac..a77bee5 100644 --- a/Swift/ApiDateFormattingService.swift.twig +++ b/Swift/ApiDateFormattingService.swift.twig @@ -1,10 +1,13 @@ {%- import 'macroses/common.utils.twig' as utils -%} {%- import 'macroses/class.utils.twig' as classUtils -%} +{%- set hasDateFormats = dateFormats is not empty -%} + +{%- if hasDateFormats %} import LeadKit import SwiftDate -enum ApiDateFormat: String, LeadKit.DateFormat, Singleton { +enum ApiDateFormat: String, LeadKit.DateFormat { {% for format in dateFormats -%} {%- set classType = classUtils.classType(format.type) -%} @@ -16,7 +19,7 @@ enum ApiDateFormat: String, LeadKit.DateFormat, Singleton { } -final class ApiDateFormattingService: DateFormattingService { +final class ApiDateFormattingService: DateFormattingService, Singleton { typealias DateFormatType = ApiDateFormat @@ -27,3 +30,4 @@ final class ApiDateFormattingService: DateFormattingService { private init() {} } +{%- endif -%} \ No newline at end of file