summaryrefslogtreecommitdiffstats
path: root/back/qver/options.go
diff options
context:
space:
mode:
Diffstat (limited to 'back/qver/options.go')
-rw-r--r--back/qver/options.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/back/qver/options.go b/back/qver/options.go
new file mode 100644
index 0000000..41385ce
--- /dev/null
+++ b/back/qver/options.go
@@ -0,0 +1,32 @@
+package qver
+
+type Option func(*options)
+
+type options struct {
+ parent *Version
+ UpdateFunc
+ state interface{}
+}
+
+func parse(opts ...Option) options {
+ var o options
+ for _, opt := range opts {
+ opt(&o)
+ }
+ return o
+}
+
+// Whenever the version changes, bump the parent's version as well.
+func Parent(p *Version) Option {
+ return func(o *options) {
+ o.parent = p
+ }
+}
+
+// Call f(state) to update the version whenever Version.Get() is called.
+func Update(state interface{}, f UpdateFunc) Option {
+ return func(o *options) {
+ o.UpdateFunc = f
+ o.state = state
+ }
+}