package devices

import (
	"fmt"

	"golang.org/x/net/context"
)

func init() {
	storerFactories = append(storerFactories, MemstoreFactory{})
}

type MemstoreFactory struct {
}

func (m MemstoreFactory) NewStorer(ctx context.Context) (Storer, error) {
	return NewMemstore(), nil
}

func (m MemstoreFactory) TeardownStorer(storer Storer, ctx context.Context) error {
	memstorer, ok := storer.(*Memstore)
	if !ok {
		return fmt.Errorf("Storer was not a *Memstore, was a %T", storer)
	}
	memstorer.devices = nil
	return nil
}
