Add extra OnPlace/OnProfile/OnRelationship/OnTombstone functions
This commit is contained in:
parent
7d6b9976bf
commit
c64f3ce904
10
place.go
10
place.go
|
@ -228,3 +228,13 @@ func ToPlace(it Item) (*Place, error) {
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("unable to convert %q", it.GetType())
|
return nil, fmt.Errorf("unable to convert %q", it.GetType())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type withPlaceFn func (*Place) error
|
||||||
|
|
||||||
|
func OnPlace(it Item, fn withPlaceFn) error {
|
||||||
|
ob, err := ToPlace(it)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return fn(ob)
|
||||||
|
}
|
||||||
|
|
10
profile.go
10
profile.go
|
@ -196,3 +196,13 @@ func ToProfile(it Item) (*Profile, error) {
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("unable to convert %q", it.GetType())
|
return nil, fmt.Errorf("unable to convert %q", it.GetType())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type withProfileFn func (*Profile) error
|
||||||
|
|
||||||
|
func OnProfile(it Item, fn withProfileFn) error {
|
||||||
|
ob, err := ToProfile(it)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return fn(ob)
|
||||||
|
}
|
||||||
|
|
|
@ -211,3 +211,13 @@ func ToRelationship(it Item) (*Relationship, error) {
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("unable to convert %q", it.GetType())
|
return nil, fmt.Errorf("unable to convert %q", it.GetType())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type withRelationshipFn func (*Relationship) error
|
||||||
|
|
||||||
|
func OnRelationship(it Item, fn withRelationshipFn) error {
|
||||||
|
ob, err := ToRelationship(it)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return fn(ob)
|
||||||
|
}
|
||||||
|
|
10
tombstone.go
10
tombstone.go
|
@ -203,3 +203,13 @@ func ToTombstone(it Item) (*Tombstone, error) {
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("unable to convert %q", it.GetType())
|
return nil, fmt.Errorf("unable to convert %q", it.GetType())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type withTombstoneFn func (*Tombstone) error
|
||||||
|
|
||||||
|
func OnTombstone(it Item, fn withTombstoneFn) error {
|
||||||
|
ob, err := ToTombstone(it)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return fn(ob)
|
||||||
|
}
|
||||||
|
|
Reference in a new issue