This file is indexed.

/usr/share/perl5/Catmandu/Fix/Condition.pm is in libcatmandu-perl 1.0700-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package Catmandu::Fix::Condition;

use Catmandu::Sane;

our $VERSION = '1.07';

use Moo::Role;
use namespace::clean;
use Catmandu::Fix::reject;

with 'Catmandu::Fix::Base';

has pass_fixes => (is => 'rw', default => sub {[]});
has fail_fixes => (is => 'rw', default => sub {[]});

sub import {
    my $target = caller;
    my ($fix, %opts) = @_;

    if (my $sym = $opts{as}) {
        my $sub = sub {
            my $data = shift;
            if ($opts{clone}) {
                $data = Clone::clone($data);
            }
            my $cond = $fix->new(@_);
            $cond->fail_fixes([Catmandu::Fix::reject->new]);
            !!$cond->fix($data);
        };
        no strict 'refs';
        *{"${target}::$sym"} = $sub;
    }
}

1;

__END__

=pod

=head1 NAME

Catmandu::Fix::Condition - Role for all Catmandu::Fix conditionals

=head1 SYNOPSIS

	if <Catmandu::Fix::Condition instance>
		<pass_fixes>
	else
		<fail_fixes>
	end

=head1 DESCRIPTION 

All L<Catmandu::Fix> conditions need to implement Catmandu::Fix::Condition.
This subclass of L<Catmandu::Fix::Base> provides a list of fixes that need to
be executed when a conditional matches (pass_fixes) and conditional that need
to be executed when a conditional fails (fail_fixes).

Conditions can be used as inline fixes as well:

    use Catmandu::Fix::Condition::exists as => 'has_field';
    
    my $item = { foo => { bar => 1 } };

    has_field($item, 'foo.bar');    # true
    has_field($item, 'doz');        # false

=head1 EXAMPLES

Catmandu core comes with the following conditions:

=over

=item 

L<all_equal|Catmandu::Fix::Condition::all_equal>

=item 

L<all_match|Catmandu::Fix::Condition::all_match>

=item

L<any_equal|Catmandu::Fix::Condition::any_equal>

=item

L<any_match|Catmandu::Fix::Condition::any_match>

=item 

L<exists|Catmandu::Fix::Condition::exists>

=item 

L<greater_than|Catmandu::Fix::Condition::greater_than>

=item 

L<in|Catmandu::Fix::Condition::in>

=item

L<is_array|Catmandu::Fix::Condition::is_array>

=item

L<is_false|Catmandu::Fix::Condition::is_false>

=item

L<is_null|Catmandu::Fix::Condition::is_null>

=item

L<is_number|Catmandu::Fix::Condition::is_number>

=item

L<is_object|Catmandu::Fix::Condition::is_object>

=item

L<is_string|Catmandu::Fix::Condition::is_string>

=item

L<is_true|Catmandu::Fix::Condition::is_true>

=item 

L<less_than|Catmandu::Fix::Condition::less_than>

=back

=cut