File: Composite.pm

package info (click to toggle)
libextutils-builder-perl 0.020-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 280 kB
  • sloc: perl: 1,391; makefile: 2
file content (88 lines) | stat: -rw-r--r-- 1,621 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package ExtUtils::Builder::Action::Composite;
$ExtUtils::Builder::Action::Composite::VERSION = '0.020';
use strict;
use warnings;

use parent 'ExtUtils::Builder::Action';

sub _preference_map {
	return {
		flatten => 3,
		execute => 2,
		command => 1,
		code    => 0,
	};
}

sub execute {
	my ($self, %opts) = @_;
	$_->execute(%opts) for $self->flatten(%opts);
	return;
}

sub to_code {
	my ($self, %opts) = @_;
	return map { $_->to_code(%opts) } $self->flatten(%opts);
}

sub to_command {
	my ($self, %opts) = @_;
	return map { $_->to_command(%opts) } $self->flatten(%opts);
}

1;

# ABSTRACT: A base role for composite action classes

__END__

=pod

=encoding UTF-8

=head1 NAME

ExtUtils::Builder::Action::Composite - A base role for composite action classes

=head1 VERSION

version 0.020

=head1 DESCRIPTION

This is a base-role for all composite action classes

=head1 METHODS

=head2 preference

This will prefer handling methods in the following order: flatten, execute, command, code

=head2 execute

Execute all actions in this collection.

=head2 to_command

This returns the list commands of all actions in the collection.

=head2 to_code

This returns the list of evaluatable strings of all actions in the collection.

=head2 preference

This will prefer handling methods in the following order: flatten, execute, command, code

=head1 AUTHOR

Leon Timmermans <fawaka@gmail.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Leon Timmermans.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut