App-Oozie

 view release on metacpan or  search on metacpan

lib/App/Oozie/Role/Meta.pm  view on Meta::CPAN

package App::Oozie::Role::Meta;

use 5.014;
use strict;
use warnings;

our $VERSION = '0.020'; # VERSION

use namespace::autoclean -except => [qw/_options_data _options_config/];

use App::Oozie::Deploy::Validate::Meta;
use Moo::Role;
use Types::Standard qw( InstanceOf Str );

with qw(
    App::Oozie::Role::Fields::Generic
);

has meta => (
    is      => 'ro',
    isa     => InstanceOf['App::Oozie::Deploy::Validate::Meta'],
    default => sub {
        my $self = shift;
        App::Oozie::Deploy::Validate::Meta->new(
            ( verbose => $self->verbose ? 1 : 0 ),
        );
    },
    lazy => 1,
);

sub probe_meta {
    my $self  = shift;
    my $rs    = $self->meta->maybe_decode || {};
    my %vars = (
        user => $self->effective_username,
    );

    if ( my $owner = $rs->{ownership} ) {
        for my $tuple (
            [qw( justification   justification )],
            [qw( owner           org_id        )],
        ) {
            my($target_name, $source_name) = @{ $tuple };
            my $value = $owner->{ $source_name } // next;
            $vars{ $target_name } = $value;
        }
    }

    return %vars;
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::Oozie::Role::Meta

=head1 VERSION

version 0.020

=head1 SYNOPSIS



( run in 0.393 second using v1.01-cache-2.11-cpan-56fb94df46f )