Add toString to nat.Entry
This commit is contained in:
@@ -47,7 +47,7 @@
|
||||
(prop &mut :Entry->Dynamic defaultInitializer null)
|
||||
|
||||
(method :Entry createEntry [:Entry->Dynamic initializer] // initializer returns Dynamic so ->:Void isn't required
|
||||
(let [e (_newEntry)]
|
||||
(let [e (new Entry)]
|
||||
(when defaultInitializer
|
||||
(defaultInitializer e))
|
||||
(initializer e)
|
||||
@@ -73,11 +73,5 @@
|
||||
(method fullString [:Entry e]
|
||||
(haxe.Json.stringify e null "\t"))
|
||||
|
||||
(function :Entry _newEntry []
|
||||
(object
|
||||
id (Uuid.v4)
|
||||
components (new Map)
|
||||
files []))
|
||||
|
||||
(method filePath [file]
|
||||
(joinPath archiveDir "files" file))
|
@@ -1,7 +1,18 @@
|
||||
package nat;
|
||||
|
||||
typedef Entry = {
|
||||
id:String,
|
||||
components:Map<String, String>,
|
||||
files:Array<FileRef>
|
||||
};
|
||||
import uuid.Uuid;
|
||||
|
||||
@:jsonParse(function (json) return new nat.Entry(json.id, json.components, json.files))
|
||||
class Entry {
|
||||
public var id:String;
|
||||
public var components:Map<String, String> = [];
|
||||
public var files:Array<FileRef> = [];
|
||||
function toString() {
|
||||
return if (components.exists("Name")) components["Name"] else 'entry $id';
|
||||
}
|
||||
public function new(?id:String, ?components:Map<String,String>, ?files:Array<String>) {
|
||||
this.id = if (id != null) id else Uuid.v4();
|
||||
if (components != null) this.components = components;
|
||||
if (files != null) this.files = files;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user