diff --git a/collection.go b/collection.go index b2e6620..42da12b 100644 --- a/collection.go +++ b/collection.go @@ -296,7 +296,7 @@ func (col *Collection) Rm(recursive bool, force bool) error { return nil } -// Attribute gets specific metadata AVU triple for Collection +// Attribute gets slice of Meta AVU triples, matching by Attribute name for Collection func (col *Collection) Attribute(attr string) (Metas, error) { if mc, err := col.Meta(); err == nil { return mc.Get(attr) diff --git a/dataobj.go b/dataobj.go index d1505fe..becf3a3 100644 --- a/dataobj.go +++ b/dataobj.go @@ -582,7 +582,7 @@ func (obj *DataObj) Stat() (map[string]interface{}, error) { return result, nil } -// Attribute returns a single Meta triple struct found by the attributes name +// Attribute gets slice of Meta AVU triples, matching by Attribute name for DataObj func (obj *DataObj) Attribute(attrName string) (Metas, error) { if meta, err := obj.Meta(); err == nil { return meta.Get(attrName) diff --git a/meta.go b/meta.go index 4a1b986..14461ee 100644 --- a/meta.go +++ b/meta.go @@ -22,6 +22,7 @@ type Meta struct { type Metas []*Meta +// MatchOne returns a single Meta struct from the slice, matching on Attribute, Value, and Units func (ms Metas) MatchOne(m *Meta) *Meta { if len(ms) > 0 { @@ -300,8 +301,8 @@ func (mc *MetaCollection) String() string { return str } -// One finds a single Meta struct by it's Attribute field. Similar to Attribute() function of other types. -func (mc *MetaCollection) One(attr string) (*Meta, error) { +// First finds the first matching Meta struct by it's Attribute field +func (mc *MetaCollection) First(attr string) (*Meta, error) { if err := mc.init(); err != nil { return nil, err } @@ -315,7 +316,7 @@ func (mc *MetaCollection) One(attr string) (*Meta, error) { return nil, newError(Fatal, fmt.Sprintf("iRods Get Meta Failed, no match")) } -// One finds a single Meta struct by it's Attribute field. Similar to Attribute() function of other types. +// Get returns a Meta struct slice (since attributes can share the same name in iRods), matching by their Attribute field. Similar to Attribute() function of other types func (mc *MetaCollection) Get(attr string) (Metas, error) { if err := mc.init(); err != nil { return nil, err @@ -336,7 +337,7 @@ func (mc *MetaCollection) Get(attr string) (Metas, error) { return result, nil } -// All +// All returns a slice of all Meta structs in the MetaCollection func (mc *MetaCollection) All() (Metas, error) { if err := mc.init(); err != nil { return nil, err @@ -345,7 +346,7 @@ func (mc *MetaCollection) All() (Metas, error) { return mc.Metas, nil } -// Each +// Each accepts an iterator function for looping over all Meta structs in the MetaCollection func (mc *MetaCollection) Each(iterator func(*Meta)) error { if err := mc.init(); err != nil { return err @@ -432,7 +433,7 @@ func (mc *MetaCollection) Add(m Meta) (*Meta, error) { if am := attrs.MatchOne(&m); am != nil { return am, nil } - return nil, er + return nil, newError(Fatal, fmt.Sprintf("iRods Add Meta Error: Unable to locate added meta triple")) } else { return nil, er }