This repository was archived by the owner on Dec 1, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -287,6 +287,37 @@ func (r Schema) Counters() Counters {
287
287
}
288
288
}
289
289
290
+ /*
291
+ Push assigns the input instance of [Definition] to the appropriate
292
+ underlying collection. The input instance MUST be compliant.
293
+
294
+ This is a fluent method.
295
+ */
296
+ func (r Schema ) Push (def Definition ) Schema {
297
+ if ! r .IsZero () && def .Compliant () {
298
+ switch def .Type () {
299
+ case `ldapSyntax` :
300
+ r .LDAPSyntaxes ().Push (def )
301
+ case `matchingRule` :
302
+ r .MatchingRules ().Push (def )
303
+ case `attributeType` :
304
+ r .AttributeTypes ().Push (def )
305
+ case `matchingRuleUse` :
306
+ r .MatchingRuleUses ().Push (def )
307
+ case `objectClass` :
308
+ r .ObjectClasses ().Push (def )
309
+ case `dITContentRule` :
310
+ r .DITContentRules ().Push (def )
311
+ case `nameForm` :
312
+ r .NameForms ().Push (def )
313
+ case `dITStructureRule` :
314
+ r .DITStructureRules ().Push (def )
315
+ }
316
+ }
317
+
318
+ return r
319
+ }
320
+
290
321
/*
291
322
ParseRaw returns an error following an attempt to parse raw into
292
323
usable schema definitions. This method operates similarly to the
Original file line number Diff line number Diff line change @@ -48,6 +48,24 @@ func ExampleSchema_Options() {
48
48
// Output: true
49
49
}
50
50
51
+ /*
52
+ This example demonstrates a convenient means of adding any [Definition]
53
+ qualifier, such as an [ObjectClass] instance, to the schema. This is
54
+ useful when manual type verification is cumbersome.
55
+ */
56
+ func ExampleSchema_Push () {
57
+ def := mySchema .NewObjectClass ()
58
+ def .SetNumericOID (`1.3.6.1.4.1.56521.999.1232` )
59
+ def .SetKind (AuxiliaryKind )
60
+ def .SetName (`exampleClass` )
61
+
62
+ mySchema .Push (def )
63
+ get := mySchema .ObjectClasses ().Get (`exampleClass` )
64
+
65
+ fmt .Printf ("%s\n " , get .OID ())
66
+ // Output: exampleClass
67
+ }
68
+
51
69
func ExampleSchema_Replace_objectClass () {
52
70
53
71
gon := mySchema .ObjectClasses ().Get (`groupOfNames` )
You can’t perform that action at this time.
0 commit comments