our
$VERSION
=
'0.500004'
;
$VERSION
=~
tr
/_//d;
has
_entry
=> (
is
=>
'rw'
,
handles
=> {
is_empty
=>
'has_entries'
,
add_changes
=>
'add_entry'
,
},
lazy
=> 1,
default
=> qsub
q{ CPAN::Changes::Entry->new(text => '') }
,
predicate
=> 1,
);
sub
name {
my
$self
=
shift
;
my
$entry
=
$self
->_entry;
return
$entry
->can(
'text'
) ?
$entry
->text :
''
;
}
sub
_maybe_entry {
my
$self
=
shift
;
if
(
$self
->can(
'changes'
) == \
&changes
) {
return
$self
->_entry;
}
else
{
return
CPAN::Changes::Entry->new(
text
=>
$self
->name,
entries
=>
$self
->changes,
);
}
}
around
BUILDARGS
=>
sub
{
my
(
$orig
,
$self
,
@args
) =
@_
;
my
$args
=
$self
->
$orig
(
@args
);
if
(!
$args
->{_entry}) {
$args
->{_entry} = CPAN::Changes::Entry->new({
text
=>
$args
->{name} ||
''
,
entries
=>
$args
->{changes} || [],
});
}
$args
;
};
sub
changes {
my
(
$self
) =
@_
;
return
[]
unless
$self
->_has_entry;
[
map
{
$_
->text } @{
$self
->_entry->entries } ];
}
sub
set_changes {
my
(
$self
,
@changes
) =
@_
;
$self
->clear_changes;
my
$entry
=
$self
->_entry;
for
my
$change
(
@changes
) {
$entry
->add_entry(
$change
);
}
return
;
}
sub
clear_changes {
my
(
$self
) =
@_
;
my
$entry
=
$self
->_entry;
@{
$entry
->entries} = ();
$self
->changes;
}
sub
serialize {
my
(
$self
,
%args
) =
@_
;
$args
{indents} ||= [
' '
,
' '
];
$args
{styles} ||= [
'[]'
,
'-'
];
$self
->_maybe_entry->serialize(
%args
);
}
1;