File: Charlie.pm

package info (click to toggle)
libclass-tiny-perl 1.008-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 284 kB
  • sloc: perl: 442; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 420 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use 5.006;
use strict;
use warnings;

package Charlie;

use subs qw/bar baz/;

use Class::Tiny qw/foo bar/, { baz => 23 };

sub bar {
    my $self = shift;
    if (@_) {
        $self->{bar} = [@_];
    }
    return $self->{bar};
}

sub baz {
    my $self = shift;
    if (@_) {
        $self->{baz} = shift;
    }
    return $self->{baz} ||=
      Class::Tiny->get_all_attribute_defaults_for( ref $self )->{baz};
}

1;