Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Commit

Permalink
coreapi: Pin option for Object.Put
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
  • Loading branch information
magik6k committed Aug 1, 2018
1 parent ebc2b35 commit ca13e9b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions options/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type ObjectNewSettings struct {
type ObjectPutSettings struct {
InputEnc string
DataType string
Pin bool
}

type ObjectAddLinkSettings struct {
Expand Down Expand Up @@ -35,6 +36,7 @@ func ObjectPutOptions(opts ...ObjectPutOption) (*ObjectPutSettings, error) {
options := &ObjectPutSettings{
InputEnc: "json",
DataType: "text",
Pin: false,
}

for _, opt := range opts {
Expand Down Expand Up @@ -103,6 +105,15 @@ func (objectOpts) DataType(t string) ObjectPutOption {
}
}

// WithPin is an option for Object.Put which specifies whether to pin the added
// objects, default is false
func (objectOpts) WithPin(pin bool) ObjectPutOption {
return func(settings *ObjectPutSettings) error {
settings.Pin = pin
return nil
}
}

// Create is an option for Object.AddLink which specifies whether create required
// directories for the child
func (objectOpts) Create(create bool) ObjectAddLinkOption {
Expand Down

0 comments on commit ca13e9b

Please sign in to comment.