Skip to content

Commit

Permalink
(feat)Add method JSONLogic.Clone.
Browse files Browse the repository at this point in the history
  • Loading branch information
huangjunwen committed Sep 23, 2020
1 parent 36eb902 commit d0d944d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions jsonlogic.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,19 @@ func AddOperation(name string, op Operation) {
func (jl *JSONLogic) AddOperation(name string, op Operation) {
jl.ops[name] = op
}

// Clone is equivalent to DefaultJSONLogic.Clone.
func Clone() *JSONLogic {
return DefaultJSONLogic.Clone()
}

// Clone clones a JSONLogic instance.
func (jl *JSONLogic) Clone() *JSONLogic {
ret := &JSONLogic{
ops: make(map[string]Operation),
}
for k, v := range jl.ops {
ret.ops[k] = v
}
return ret
}

0 comments on commit d0d944d

Please sign in to comment.