// Copyright (C) 2019 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package data import ( "github.com/dotchain/dot/changes" "github.com/dotchain/dot/changes/types" ) // Dir wraps a value along with a map of objects. The contents of the // value can refer to entries in the map using Ref type Dir struct { Root changes.Value Objects types.M } // Name returns the key name for use with Attrs func (d *Dir) Name() string { return "Embed" } // Apply implements channges.Value func (d *Dir) Apply(ctx changes.Context, c changes.Change) changes.Value { return (types.Generic{Set: d.set, Get: d.get}).Apply(ctx, c, d) } func (d *Dir) get(key interface{}) changes.Value { if key == "Root" { return d.Root } return d.Objects } func (d *Dir) set(key interface{}, v changes.Value) changes.Value { clone := *d if key == "Root" { clone.Root = v } else { clone.Objects = v.(types.M) } return &clone }
Related articles
dot branch_test
// Copyright (C) 2019 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package streams_test import ( "testing" "github.com/dotchain/dot/changes" "github.com/dotch
dot errors
// Copyright (C) 2019 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package eval import ( "errors" "strconv" ) // the following are runtime errors var errRecurs
dot refs_test
// Copyright (C) 2018 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package refs_test import ( "github.com/dotchain/dot/changes" "github.com/dotchain/dot/changes
dot union
// Copyright (C) 2019 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package dotc import ( "io" "text/template" ) // Union has the type information of a union fo
dot generic
// Copyright (C) 2018 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package types import "github.com/dotchain/dot/changes" // Generic is a helper to build value a
dot ord
// Copyright (C) 2019 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package crdt import ( "math/big" "strconv" "strings" ) // NextOrd returns the next ordinal.
dot heading_test
// Copyright (C) 2019 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package data_test import ( "reflect" "testing" "github.com/dotchain/dot/changes" "github.c
dot typename
// Copyright (C) 2018 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package sjson import ( "errors" "reflect" "strconv" "strings" "time" ) func typeName(v re
dot go
github.com/etcd-io/bbolt v1.3.2 h1:RLRQ0TKLX7DlBRXAJHvbmXL17Q3KNnTBtZ9B6Qo+/Y0= github.com/etcd-io/bbolt v1.3.2/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.
dot setattr_test
// Copyright (C) 2019 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package rich_test import ( "testing" "github.com/dotchain/dot/changes" "github.com/dotchain