Renamed OnPerson to OnActor

This commit is contained in:
Marius Orcsik 2019-12-03 21:53:11 +01:00
parent b8b0448aff
commit 48db6d24ad
No known key found for this signature in database
GPG key ID: 77618B618F79EB72
2 changed files with 6 additions and 6 deletions

View file

@ -9,7 +9,7 @@ type withObjectFn func (*Object) error
type withActivityFn func (*Activity) error
type withIntransitiveActivityFn func (*IntransitiveActivity) error
type withQuestionFn func (*Question) error
type withPersonFn func (*Person) error
type withActorFn func (*Actor) error
type withCollectionInterfaceFn func (collection CollectionInterface) error
type withCollectionFn func (collection *Collection) error
type withCollectionPageFn func (*CollectionPage) error
@ -28,7 +28,7 @@ func OnObject(it Item, fn withObjectFn) error {
return fn(ob)
})
} else if ActorTypes.Contains(it.GetType()) {
return OnPerson(it, func(p *Person) error {
return OnActor(it, func(p *Actor) error {
ob, err := ToObject(p)
if err != nil {
return err
@ -93,8 +93,8 @@ func OnQuestion(it Item, fn withQuestionFn) error {
return fn(act)
}
// OnPerson
func OnPerson(it Item, fn withPersonFn) error {
// OnActor
func OnActor(it Item, fn withActorFn) error {
if !ActorTypes.Contains(it.GetType()) {
return errors.New(fmt.Sprintf("%T[%s] can't be converted to Person", it, it.GetType()))
}

View file

@ -107,7 +107,7 @@ func TestOnQuestion(t *testing.T) {
func TestOnPerson(t *testing.T) {
pers := PersonNew("testPerson")
err := OnPerson(pers, func(a *Person) error {
err := OnActor(pers, func(a *Person) error {
return nil
})
@ -115,7 +115,7 @@ func TestOnPerson(t *testing.T) {
t.Errorf("Unexpected error returned %s", err)
}
err = OnPerson(pers, func(p *Person) error {
err = OnActor(pers, func(p *Person) error {
if p.Type != pers.Type {
t.Errorf("In function type %s different than expected, %s", p.Type, pers.Type)
}