What qualify as scopes?
Top-level nodes which appear under a tag dedicated to represent
scope override qualify as scopes.
How is scope override defined?
Scope override definition is defined under a config driven tag dedicated
for scope override. In the example below in (fig 1), the tag happens to be
scope_override and scopes are x, y & z. Scopes y and z are the overrider
scopes and x is the default scope.
How is scope overriding done?
There are not more than 2 scopes participating in a scope override at any time.
That is, either the user chooses to use the scope y, in which case y overrides x
OR the user chooses to use scope z, in which case z overrides x
OR user chooses to not use any scope, in which case no overriding is done at all.
Also note that y and z are totally unrelated and never participate together in
scope overriding. Before explaining the logic of scope overriding, please note
the convention in the example below
-
Any node that starts with p represents a primitive node. In other
words, it represents a config-key and a node that starts with v
represents the config-value.
-
Nodes x, y, z represent scopes as explained in the previous question.
-
Rest of nodes [a-g] represent internal nodes.
(fig 1)
├── scope_override
│ ├── {y = x}
│ └── {z = x}
│
├── x
│ └── a
│ ├── b
│ │ ├── c
│ │ │ ├── d
│ │ │ │ ├── {p3 = v3_x}
│ │ │ │ └── {p4 = v4_x}
│ │ │ └── {p2 = v2_x}
│ │ └── {p1 = v1_x}
│ └── e
│ └── f
│ └── {p5 = v5_x}
├── y
│ └── a
│ └── b
│ ├── c
│ │ ├── d
│ │ │ ├── {p3 = v3_y}
│ │ │ └── {p4 = v4_y}
│ │ └── {p2 = v2_y}
│ └── {p1 = v1_y}
└── z
└── a
└── b
├── c
│ ├── d
│ │ ├── {p3 = v3_z}
│ │ └── {p7 = v7_z}
│ └── {p2 = v2_z}
├── g
│ └── {p6 = v6_z}
└── {p1 = v1_z}
Overriding is done by replacing the value of a config-key that appears
in both the scopes, along the exact same hierarchy.
When scope y overrides x, the final config-key values resolved are below.
It inherits p5 as is from x. Overrides p1, p2, p3, p4.
(fig 2)
a
├── b
│ ├── c
│ │ ├── d
│ │ │ ├── {p3 = v3_y}
│ │ │ └── {p4 = v4_y}
│ │ └── {p2 = v2_y}
│ └── {p1 = v1_y}
└── e
└── f
└── {p5 = v5_x}
When scope z overrides x, the final config-key values resolved are below.
It inherits p5 as is from x. Overrides p1, p2, p3, p4. Retains its p6.
(fig 3)
a
├── b
│ ├── c
│ │ ├── d
│ │ │ ├── {p3 = v3_z}
│ │ │ └── {p4 = v4_z}
│ │ │ └── {p7 = v7_z}
│ │ └── {p2 = v2_z}
│ ├── g
│ │ └── {p6 = v6_z}
│ └── {p1 = v1_y}
└── e
└── f
└── {p5 = v5_x}