49 lines
837 B
Swift
49 lines
837 B
Swift
//
|
|
// Repository.swift
|
|
// Piper ~ App
|
|
//
|
|
// Created by Javier Cicchelli on 05/10/2024.
|
|
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import SwiftData
|
|
|
|
@Model
|
|
final class Repository {
|
|
|
|
// MARK: Properties
|
|
|
|
@Attribute(.unique) var path: URL
|
|
|
|
var addedAt: Date
|
|
var active: Bool
|
|
|
|
// MARK: Initialisers
|
|
|
|
init(
|
|
_ path: URL,
|
|
active: Bool = true,
|
|
addedAt: Date = .now
|
|
) {
|
|
self.path = path
|
|
self.addedAt = addedAt
|
|
self.active = active
|
|
}
|
|
|
|
// MARK: Computed
|
|
|
|
@Transient var folder: String {
|
|
path.deletingLastPathComponent().relativePath
|
|
}
|
|
|
|
@Transient var name: String {
|
|
path.lastPathComponent
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - Identifiable
|
|
|
|
extension Repository: Identifiable {}
|