|
|
@ -8,6 +8,15 @@ import ( |
|
|
|
|
|
|
|
// One makes a ChangeKey for a model, or panics if it's not supported.
|
|
|
|
func One(object interface{}) models.ChangeKey { |
|
|
|
switch v := object.(type) { |
|
|
|
case models.Post: |
|
|
|
return models.ChangeKey{Model: "Post", ID: v.ID} |
|
|
|
case models.Character: |
|
|
|
return models.ChangeKey{Model: "Character", ID: v.ID} |
|
|
|
case models.Channel: |
|
|
|
return models.ChangeKey{Model: "Channel", ID: v.Name} |
|
|
|
} |
|
|
|
|
|
|
|
model := "" |
|
|
|
if t := reflect.TypeOf(object); t.Kind() == reflect.Ptr { |
|
|
|
model = t.Elem().Name() |
|
|
|