File: MemberMixin.pm

package info (click to toggle)
libhttp-oai-perl 4.03-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 416 kB
  • ctags: 326
  • sloc: perl: 2,531; xml: 224; makefile: 12
file content (54 lines) | stat: -rw-r--r-- 825 bytes parent folder | download
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package HTTP::OAI::MemberMixin;

@ISA = qw( LWP::MemberMixin );

sub new
{
	my( $class, %self ) = @_;
	return bless \%self, $class;
}

sub harvester { shift->_elem("harvester",@_) }

sub _multi
{
	my( $self, $elem ) = splice(@_, 0, 2);
	if( ref($_[0]) eq "ARRAY" )
	{
		$self->{$elem} = $_[0];
	}
	elsif( @_ )
	{
		push @{$self->{$elem}}, @_;
	}
	return @{$self->{$elem} || []};
}

1;

=head1 NAME

HTTP::OAI::MemberMixin - Attribute utility methods

=head1 DESCRIPTION

Subclasses L<LWP::MemberMixin> to provide attribute utility methods.

=head1 METHODS

=over 4

=item $obj->_elem( FIELD [, VALUE ] )

See L<LWP::MemberMixin/_elem>.

=item $obj->_multi( FIELD [, VALUE ] )

Same as L</_elem> but if you pass a non-ARRAY reference appends the given value(s).

In list context returns a list of all the items.

=back

=cut