my $config = config(
bool => true,
token => 'a single string',
value => [ 'a', 'list', 'of', 'strings' ],
blah => store( # This function leaves a "constructor" in the config, that generates a new object when traversed.
key => val, ... # Object typed and configured by these arguments...
),
...
);
...
my $object = Type->new($config); # As Type builds an object, it references $config->value(), $config->token()...
...
my $widget = $config->{path/to/some/nested/doohickey}; # This is actually a nested tree traversal underneath...
my $thingy = $widget->evaluate($with_this_context);
####
sub FETCH {
my $self = shift;
if (! @_) {
return $self->[0]->{FETCH};
}
...
}
####
$config->{FETCH} = SomeWidget->new(...);
my $response = $config->FETCH->(
term => [ 'range', 'of', 'values' ], ...
);
####
sub FIRSTKEY {
my $self = shift;
if (! @_) {
return $self->[0]->{FIRSTKEY};
}
# ... walk the tree to gather nested keys
$self->[1]->{iter} = \@list;
# $_[0] is an empty array provided by the machinery that calls ->FIRSTKEY underneath.
my $name = shift(@list);
push(@{$_[0]}, $name); # Either way works...
return $name;
}
####
# XXX: When dereferencing config keys, don't say ->FIRSTKEY, ->DESTROY, ...