Sha256: 4ac32940d262e4c645e23854ea5067023800aa22f42602698d4f6b0674d54849

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

struct PropertyData {
	let name: String
	let value: Any
	let destinations: [Destination]

	init(name: String, value: Any, destinations: [Destination]) {
		self.name = name
		self.value = value
		self.destinations = destinations
	}

	init(type: PropertyType, value: Any) {
		self.init(name: type.name, value: value, destinations: type.destinations)
	}
}

enum PropertyType: String {
	<%- properties.each do |p| -%>
	case <%= p[:case_name] %> = "<%= p[:property_name ] %>"
	<%- end -%>

	var name: String { return rawValue }

	var destinations: [Destination] {
		switch self {
		<%- properties.each_with_index do |p, index| -%>
		case .<%= p[:case_name] %>: return [<%= p[:destinations].map { |d| ".#{d}" }.join(", ") %>]
		<%- end -%>
		}
	}
}

enum Property {
	<%- properties.each do |p| -%>
	case <%= p[:case_name] %>(<%= p[:type] %>)
	<%- end -%>

	var data: PropertyData {
		switch self {
		<%- properties.each_with_index do |p, index| -%>
		case let .<%= p[:case_name] %>(value):
			return PropertyData(type: .<%= p[:case_name] %>,
								value: value<% if p[:is_special_property] %>.rawValue<% end %>)
			<%- unless index == properties.count - 1 -%>

			<%- end -%>
		<%- end -%>
		}
	}
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
evva-0.5.0 lib/evva/templates/swift/people_properties.swift
evva-0.4.4 lib/evva/templates/swift/people_properties.swift
evva-0.4.3 lib/evva/templates/swift/people_properties.swift
evva-0.4.2 lib/evva/templates/swift/people_properties.swift
evva-0.4.1 lib/evva/templates/swift/people_properties.swift