2014-09-25 04:46:09 +00:00
|
|
|
package capability
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.google.com/p/go.net/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Capability map[string]bool
|
|
|
|
|
|
|
|
// Get the capability value from the map.
|
|
|
|
func (c Capability) Get(key string) bool {
|
2014-10-01 16:58:17 +00:00
|
|
|
return c[key]
|
2014-09-25 04:46:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sets the capability value in the map.
|
|
|
|
func (c Capability) Set(key string, value bool) {
|
|
|
|
c[key] = value
|
|
|
|
}
|
|
|
|
|
|
|
|
// Enabled returns true if the capability is
|
|
|
|
// enabled in the system.
|
|
|
|
func Enabled(c context.Context, key string) bool {
|
|
|
|
return FromContext(c).Get(key)
|
|
|
|
}
|