Documentation
¶
Index ¶
- type DataObject
- func New() *DataObject
- func NewDataObject() *DataObjectdeprecated
- func NewDataObjectFromExistingData(data map[string]string) *DataObjectdeprecated
- func NewDataObjectFromJSON(jsonString string) (do *DataObject, err error)deprecated
- func NewFromData(data map[string]string) *DataObject
- func NewFromGob(gobData []byte) (*DataObject, error)
- func NewFromJSON(jsonString string) (*DataObject, error)
- func (do *DataObject) Data() map[string]string
- func (do *DataObject) DataChanged() map[string]string
- func (do *DataObject) Get(key string) string
- func (do *DataObject) Hydrate(data map[string]string)
- func (do *DataObject) ID() string
- func (do *DataObject) Init()
- func (do *DataObject) IsDirty() bool
- func (do *DataObject) MarkAsNotDirty()
- func (do *DataObject) Set(key string, value string)
- func (do *DataObject) SetData(data map[string]string)
- func (do *DataObject) SetID(id string)
- func (do *DataObject) ToGob() ([]byte, error)
- func (do *DataObject) ToJSON() (string, error)
- type DataObjectInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataObject ¶
type DataObject struct {
// contains filtered or unexported fields
}
func New ¶ added in v1.0.0
func New() *DataObject
New creates a new data object with a unique ID
Business logic: - instantiates a new data object - generates an ID, using uid.HumanUid()
Note! The object is marked as dirty, as ID is set
Returns: - a new data object
func NewDataObject
deprecated
func NewDataObject() *DataObject
Deprecated: NewDataObject is deprecated, use New() instead. Creates a new data object with a unique ID
func NewDataObjectFromExistingData
deprecated
func NewDataObjectFromExistingData(data map[string]string) *DataObject
Deprecated: NewDataObjectFromExistingData is deprecated, use NewFromData() instead. Creates a new data object and hydrates it with the passed data
func NewDataObjectFromJSON
deprecated
added in
v0.1.0
func NewDataObjectFromJSON(jsonString string) (do *DataObject, err error)
Deprecated: NewDataObjectFromJSON is deprecated, use NewFromJSON() instead. Creates a new data object and hydrates it with the passed JSON string
func NewFromData ¶ added in v1.0.0
func NewFromData(data map[string]string) *DataObject
NewFromData creates a new data object and hydrates it with the passed data
Note: the object is marked as not dirty, as it is existing data
Business logic: - instantiates a new data object - hydrates it with the passed data
Returns: - a new data object
func NewFromGob ¶ added in v1.0.0
func NewFromGob(gobData []byte) (*DataObject, error)
NewFromGob creates a new data object and hydrates it with the passed gob-encoded byte array.
The gob data is expected to be an encoded map[string]string ¶
Note: the object is marked as not dirty, as it is existing data
Business logic: - instantiates a new data object - decodes the gob data - hydrates it with the decoded data
Returns: - a new data object - an error if any
func NewFromJSON ¶ added in v1.0.0
func NewFromJSON(jsonString string) (*DataObject, error)
NewFromJSON creates a new data object and hydrates it with the passed JSON string.
The JSON string is expected to be a valid DataObject JSON object ¶
Note: the object is marked as not dirty, as it is existing data
Business logic: - instantiates a new data object - hydrates it with the passed JSON string
Returns: - a new data object - an error if any
func (*DataObject) Data ¶
func (do *DataObject) Data() map[string]string
Data returns all the data of the object
func (*DataObject) DataChanged ¶
func (do *DataObject) DataChanged() map[string]string
DataChanged returns only the modified data
func (*DataObject) Hydrate ¶
func (do *DataObject) Hydrate(data map[string]string)
Hydrate sets the data for the object without marking it as dirty
func (*DataObject) Init ¶
func (do *DataObject) Init()
Init initializes the data object if it is not already initialized
func (*DataObject) IsDirty ¶
func (do *DataObject) IsDirty() bool
IsDirty returns if data has been modified
func (*DataObject) MarkAsNotDirty ¶ added in v0.2.0
func (do *DataObject) MarkAsNotDirty()
MarkAsNotDirty marks the object as not dirty
func (*DataObject) Set ¶
func (do *DataObject) Set(key string, value string)
Set helper setter method
func (*DataObject) SetData ¶
func (do *DataObject) SetData(data map[string]string)
SetData sets the data for the object and marks it as dirty see Hydrate for assignment without marking as dirty
func (*DataObject) ToGob ¶ added in v1.0.0
func (do *DataObject) ToGob() ([]byte, error)
ToGob converts the DataObject to a gob-encoded byte array
Returns: - the gob-encoded byte array representation of the DataObject - an error if any
func (*DataObject) ToJSON ¶ added in v0.1.0
func (do *DataObject) ToJSON() (string, error)
ToJSON converts the DataObject to a JSON string
Returns: - the JSON string representation of the DataObject - an error if any
type DataObjectInterface ¶
type DataObjectInterface interface { // ID returns the ID of the object ID() string // SetID sets the ID of the object SetID(id string) // GetData returns the data for the object Data() map[string]string // GetChangedData returns the data that has been changed since the last hydration DataChanged() map[string]string // Hydrates the data object with data Hydrate(map[string]string) // ToJSON converts the DataObject to a JSON string ToJSON() (string, error) // ToGob converts the DataObject to a gob-encoded byte array ToGob() ([]byte, error) }
DataObjectInterface is an interface for a data object