our
$AUTHORITY
=
'cpan:DDG'
;
$DDG::Meta::Fathead::VERSION
=
'1018'
;
sub
fathead_attributes {
qw(
mediawiki
title_addon
)
}
my
%applied
;
sub
apply_keywords {
my
(
$class
,
$target
) =
@_
;
return
if
exists
$applied
{
$target
};
$applied
{
$target
} =
undef
;
my
@parts
=
split
(
'::'
,
$target
);
shift
@parts
;
shift
@parts
;
my
$answer_type
=
lc
(
join
(
' '
,
@parts
));
my
$stash
= Package::Stash->new(
$target
);
my
%zci_params
= (
answer_type
=>
$answer_type
,
);
$stash
->add_symbol(
'&fathead'
,
sub
{
if
(
ref
$_
[0] eq
'HASH'
) {
for
(
keys
%{
$_
[0]}) {
$zci_params
{check_fathead_key(
$_
)} =
$_
[0]->{
$_
};
}
}
else
{
while
(
@_
) {
my
$key
=
shift
;
my
$value
=
shift
;
$zci_params
{check_fathead_key(
$key
)} =
$value
;
}
}
});
}
sub
check_fathead_key {
my
$key
=
shift
;
if
(
grep
{
$key
eq
$_
} fathead_attributes) {
return
$key
;
}
else
{
croak
$key
.
" is not supported on DDG::Meta::Fathead"
;
}
}
1;