forked from xmidt-org/talaria
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrawAttributes.go
30 lines (24 loc) · 920 Bytes
/
rawAttributes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// SPDX-FileCopyrightText: 2017 Comcast Cable Communications Management, LLC
// SPDX-License-Identifier: Apache-2.0
package main
import "github.com/xmidt-org/bascule"
// RawAttributes is the interface that wraps methods which dictate how to interact
// with a token's attributes. It adds functionality on top of bascule Attributes by including
// a Getter for all of a token's attributes, returning a map of the attributes
type RawAttributes interface {
bascule.Attributes
GetRawAttributes() map[string]interface{}
}
type rawAttributes map[string]interface{}
func (r rawAttributes) Get(key string) (interface{}, bool) {
v, ok := r[key]
return v, ok
}
func (r rawAttributes) GetRawAttributes() map[string]interface{} {
return r
}
// NewRawAttributes builds a RawAttributes instance with
// the given map as datasource.
func NewRawAttributes(m map[string]interface{}) RawAttributes {
return rawAttributes(m)
}