MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / SaveMutatorSpec

Function SaveMutatorSpec

internal/mutators/admin.go:102–122  ·  view source on GitHub ↗
(spec *MutatorSpec)

Source from the content-addressed store, hash-verified

100}
101
102func SaveMutatorSpec(spec *MutatorSpec) error {
103 if spec.MutatorId == "" {
104 return fmt.Errorf("cannot save mutator spec with empty mutatorid")
105 }
106
107 if err := ValidateSpec(spec); err != nil {
108 return err
109 }
110
111 saveModes := []fileloader.SaveOption{}
112 if configs.GetFilePathsConfig().CarefulSaveFiles {
113 saveModes = append(saveModes, fileloader.SaveCareful)
114 }
115
116 if err := fileloader.SaveFlatFile[*MutatorSpec](configs.GetFilePathsConfig().DataFiles.String()+`/mutators`, spec, saveModes...); err != nil {
117 return err
118 }
119
120 allMutators[spec.MutatorId] = spec
121 return nil
122}
123
124func DeleteMutatorSpec(mutatorId string) error {
125 spec := GetMutatorSpec(mutatorId)

Callers 1

apiV1PatchMutatorFunction · 0.92

Calls 3

GetFilePathsConfigFunction · 0.92
ValidateSpecFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected