No need to expose implementations

This commit is contained in:
Deluan
2016-03-01 19:17:30 -05:00
parent 78805ac465
commit 6092076fad
4 changed files with 13 additions and 13 deletions
+5 -5
View File
@@ -11,30 +11,30 @@ type ArtistIndex interface {
GetAll() ([]models.ArtistIndex, error) GetAll() ([]models.ArtistIndex, error)
} }
type ArtistIndexImpl struct { type artistIndex struct {
BaseRepository BaseRepository
} }
func NewArtistIndexRepository() ArtistIndex { func NewArtistIndexRepository() ArtistIndex {
r := &ArtistIndexImpl{} r := &artistIndex{}
r.init("index", &models.ArtistIndex{}) r.init("index", &models.ArtistIndex{})
return r return r
} }
func (r *ArtistIndexImpl) Put(m *models.ArtistIndex) error { func (r *artistIndex) Put(m *models.ArtistIndex) error {
if m.Id == "" { if m.Id == "" {
return errors.New("Id is not set") return errors.New("Id is not set")
} }
return r.saveOrUpdate(m.Id, m) return r.saveOrUpdate(m.Id, m)
} }
func (r *ArtistIndexImpl) Get(id string) (*models.ArtistIndex, error) { func (r *artistIndex) Get(id string) (*models.ArtistIndex, error) {
var rec interface{} var rec interface{}
rec, err := r.readEntity(id) rec, err := r.readEntity(id)
return rec.(*models.ArtistIndex), err return rec.(*models.ArtistIndex), err
} }
func (r *ArtistIndexImpl) GetAll() ([]models.ArtistIndex, error) { func (r *artistIndex) GetAll() ([]models.ArtistIndex, error) {
var indices = make([]models.ArtistIndex, 0) var indices = make([]models.ArtistIndex, 0)
err := r.loadAll(&indices) err := r.loadAll(&indices)
return indices, err return indices, err
+6 -6
View File
@@ -11,17 +11,17 @@ type Property interface {
DefaultGet(id string, defaultValue string) (string, error) DefaultGet(id string, defaultValue string) (string, error)
} }
type PropertyImpl struct { type property struct {
BaseRepository BaseRepository
} }
func NewPropertyRepository() *PropertyImpl { func NewPropertyRepository() *property {
r := &PropertyImpl{} r := &property{}
r.init("property", &models.Property{}) r.init("property", &models.Property{})
return r return r
} }
func (r *PropertyImpl) Put(id string, value string) error { func (r *property) Put(id string, value string) error {
m := &models.Property{Id: id, Value: value} m := &models.Property{Id: id, Value: value}
if m.Id == "" { if m.Id == "" {
return errors.New("Id is required") return errors.New("Id is required")
@@ -29,13 +29,13 @@ func (r *PropertyImpl) Put(id string, value string) error {
return r.saveOrUpdate(m.Id, m) return r.saveOrUpdate(m.Id, m)
} }
func (r *PropertyImpl) Get(id string) (string, error) { func (r *property) Get(id string) (string, error) {
var rec interface{} var rec interface{}
rec, err := r.readEntity(id) rec, err := r.readEntity(id)
return rec.(*models.Property).Value, err return rec.(*models.Property).Value, err
} }
func (r* PropertyImpl) DefaultGet(id string, defaultValue string) (string, error) { func (r*property) DefaultGet(id string, defaultValue string) (string, error) {
v, err := r.Get(id) v, err := r.Get(id)
if v == "" { if v == "" {
+1 -1
View File
@@ -13,7 +13,7 @@ func CreateMockArtistIndexRepo() *MockArtistIndex {
} }
type MockArtistIndex struct { type MockArtistIndex struct {
repositories.ArtistIndexImpl repositories.ArtistIndex
data []models.ArtistIndex data []models.ArtistIndex
err bool err bool
} }
+1 -1
View File
@@ -10,7 +10,7 @@ func CreateMockPropertyRepo() *MockProperty {
} }
type MockProperty struct { type MockProperty struct {
repositories.PropertyImpl repositories.Property
data map[string]string data map[string]string
err bool err bool
} }