Skip to content

Commit

Permalink
add Module and BaseModule. Closes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
magic003 committed Apr 8, 2017
1 parent d34261b commit 7a0d076
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions module.go
@@ -0,0 +1,16 @@
package alice

// Module is a marker interface for structs that defines how to initialize instances.
type Module interface {
// IsModule indicates if this is a module.
IsModule() bool
}

// BaseModule is an implementation of Module interface. It should be embeded into each module defined in the
// application.
type BaseModule struct{}

// IsModule indicates it is a module.
func (b *BaseModule) IsModule() bool {
return true
}
12 changes: 12 additions & 0 deletions module_test.go
@@ -0,0 +1,12 @@
package alice

import (
"testing"
)

func TestBaseModule(t *testing.T) {
var base Module = &BaseModule{}
if !base.IsModule() {
t.Error("BaseModule is expected to be a Module, but it is not")
}
}

0 comments on commit 7a0d076

Please sign in to comment.