• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mlange-42 / arche-serde / 8032168232

24 Feb 2024 05:36PM CUT coverage: 95.679% (+2.1%) from 93.562%
8032168232

Pull #13

github

web-flow
Merge ff18721ad into c2c523fde
Pull Request #13: Add options to skip stuff when serializing or deserializing

135 of 137 new or added lines in 3 files covered. (98.54%)

10 existing lines in 1 file now uncovered.

310 of 324 relevant lines covered (95.68%)

36.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/options.go
1
package archeserde
2

3
import (
4
        "reflect"
5

6
        "github.com/mlange-42/arche/generic"
7
)
8

9
var Opts = Options{}
10

11
type Option func(o *serdeOptions)
12

13
type Options struct{}
14

15
func (o Options) SkipAllResources() Option {
2✔
16
        return func(o *serdeOptions) {
4✔
17
                o.skipAllResources = true
2✔
18
        }
2✔
19
}
20

21
func (o Options) SkipAllComponents() Option {
2✔
22
        return func(o *serdeOptions) {
4✔
23
                o.skipAllComponents = true
2✔
24
        }
2✔
25
}
26

27
func (o Options) SkipEntities() Option {
2✔
28
        return func(o *serdeOptions) {
4✔
29
                o.skipEntities = true
2✔
30
        }
2✔
31
}
32

33
func (o Options) SkipComponents(comps ...generic.Comp) Option {
2✔
34
        return func(o *serdeOptions) {
4✔
35
                o.skipComponents = make([]reflect.Type, len(comps))
2✔
36
                for i, c := range comps {
4✔
37
                        o.skipComponents[i] = reflect.Type(c)
2✔
38
                }
2✔
39
        }
40
}
41

42
func (o Options) SkipResources(comps ...generic.Comp) Option {
2✔
43
        return func(o *serdeOptions) {
4✔
44
                o.skipResources = make([]reflect.Type, len(comps))
2✔
45
                for i, c := range comps {
4✔
46
                        o.skipResources[i] = reflect.Type(c)
2✔
47
                }
2✔
48
        }
49
}
50

51
type serdeOptions struct {
52
        skipAllResources  bool
53
        skipAllComponents bool
54
        skipEntities      bool
55

56
        skipComponents []reflect.Type
57
        skipResources  []reflect.Type
58
}
59

60
func newSerdeOptions(opts ...Option) serdeOptions {
39✔
61
        o := serdeOptions{}
39✔
62
        for _, opt := range opts {
49✔
63
                opt(&o)
10✔
64
        }
10✔
65
        return o
39✔
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc