Hiding the Meta parameter
This commit is contained in:
parent
24db16ccf7
commit
23ba57e6a8
18
file.go
18
file.go
@ -32,7 +32,7 @@ import (
|
||||
|
||||
type file struct {
|
||||
path string
|
||||
meta map[string]interface{}
|
||||
Meta map[string]interface{}
|
||||
|
||||
reader *bytes.Reader
|
||||
asset string
|
||||
@ -93,13 +93,19 @@ func (f *file) Path() string {
|
||||
return f.path
|
||||
}
|
||||
|
||||
func (f *file) Meta() map[string]interface{} {
|
||||
return f.meta
|
||||
func (f *file) Value(key string) (interface{}, bool) {
|
||||
value, ok := f.Meta[key]
|
||||
return value, ok
|
||||
}
|
||||
|
||||
func (f *file) Apply(m map[string]interface{}) {
|
||||
for key, value := range m {
|
||||
f.meta[key] = value
|
||||
func (f *file) SetValue(key string, value interface{}) {
|
||||
f.Meta[key] = value
|
||||
}
|
||||
|
||||
func (f *file) CopyValues(src File) {
|
||||
rf := src.(*file)
|
||||
for name, value := range rf.Meta {
|
||||
f.SetValue(name, value)
|
||||
}
|
||||
}
|
||||
|
||||
|
9
types.go
9
types.go
@ -46,8 +46,9 @@ func New(srcDir, dstDir string) Goldsmith {
|
||||
type File interface {
|
||||
Path() string
|
||||
|
||||
Meta() map[string]interface{}
|
||||
Apply(m map[string]interface{})
|
||||
Value(key string) (interface{}, bool)
|
||||
SetValue(key string, value interface{})
|
||||
CopyValues(src File)
|
||||
|
||||
Read(p []byte) (int, error)
|
||||
WriteTo(w io.Writer) (int64, error)
|
||||
@ -57,7 +58,7 @@ type File interface {
|
||||
func NewFileFromData(path string, data []byte) File {
|
||||
return &file{
|
||||
path: path,
|
||||
meta: make(map[string]interface{}),
|
||||
Meta: make(map[string]interface{}),
|
||||
reader: bytes.NewReader(data),
|
||||
}
|
||||
}
|
||||
@ -65,7 +66,7 @@ func NewFileFromData(path string, data []byte) File {
|
||||
func NewFileFromAsset(path, asset string) File {
|
||||
return &file{
|
||||
path: path,
|
||||
meta: make(map[string]interface{}),
|
||||
Meta: make(map[string]interface{}),
|
||||
asset: asset,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user