| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 1 |  |  | 1 |  | 1013 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 32 |  | 
| 2 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 53 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | package ElasticSearchX::Model::Generator::Generated::Document; | 
| 5 |  |  |  |  |  |  | BEGIN { | 
| 6 | 1 |  |  | 1 |  | 26 | $ElasticSearchX::Model::Generator::Generated::Document::AUTHORITY = 'cpan:KENTNL'; | 
| 7 |  |  |  |  |  |  | } | 
| 8 |  |  |  |  |  |  | { | 
| 9 |  |  |  |  |  |  | $ElasticSearchX::Model::Generator::Generated::Document::VERSION = '0.1.8'; | 
| 10 |  |  |  |  |  |  | } | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | # ABSTRACT: A Generated C<ESX> Document Model. | 
| 13 |  |  |  |  |  |  |  | 
| 14 | 1 |  |  | 1 |  | 838 | use Moo; | 
|  | 1 |  |  |  |  | 19385 |  | 
|  | 1 |  |  |  |  | 8 |  | 
| 15 | 1 |  |  | 1 |  | 9318 | use Path::Tiny (); | 
|  | 1 |  |  |  |  | 16236 |  | 
|  | 1 |  |  |  |  | 34 |  | 
| 16 | 1 |  |  | 1 |  | 473 | use MooseX::Has::Sugar qw( rw required ); | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | has 'package' => rw, required; | 
| 20 |  |  |  |  |  |  | has 'path'    => rw, required; | 
| 21 |  |  |  |  |  |  | has 'content' => rw, required; | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | sub write { | 
| 25 |  |  |  |  |  |  | my ( $self, %args ) = @_; | 
| 26 |  |  |  |  |  |  | my $file = Path::Tiny::path( $self->path ); | 
| 27 |  |  |  |  |  |  | $file->parent->mkpath; | 
| 28 |  |  |  |  |  |  | $file->openw->print( $self->content ); | 
| 29 |  |  |  |  |  |  | return; | 
| 30 |  |  |  |  |  |  | } | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | sub evaluate { | 
| 34 |  |  |  |  |  |  | my ( $self, %args ) = @_; | 
| 35 |  |  |  |  |  |  | require Module::Runtime; | 
| 36 |  |  |  |  |  |  | my $mn = Module::Runtime::module_notional_filename( $self->package ); | 
| 37 |  |  |  |  |  |  | ## no critic (RequireLocalizedPunctuationVars) | 
| 38 |  |  |  |  |  |  | $INC{$mn} = 1; | 
| 39 |  |  |  |  |  |  | local ( $@, $! ) = (); | 
| 40 |  |  |  |  |  |  | ## no critic ( ProhibitStringyEval ) | 
| 41 |  |  |  |  |  |  | if ( not eval $self->content ) { | 
| 42 |  |  |  |  |  |  | require Carp; | 
| 43 |  |  |  |  |  |  | Carp::croak( sprintf 'content for %s did not load: %s %s', $self->package, $@, $! ); | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  | ## no critic ( RequireCarping ) | 
| 46 |  |  |  |  |  |  | die $@ if $@; | 
| 47 |  |  |  |  |  |  | return; | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  | no Moo; | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | 1; | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | __END__ | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | =pod | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | =encoding UTF-8 | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | =head1 NAME | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | ElasticSearchX::Model::Generator::Generated::Document - A Generated C<ESX> Document Model. | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | =head1 VERSION | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | version 0.1.8 | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | =head1 METHODS | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | =head2 write | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | $document->write(); | 
| 72 |  |  |  |  |  |  | # $document->path is filled with $document->content | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | =head2 evaluate | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | $document->evaluate(); | 
| 77 |  |  |  |  |  |  | my $instance = $document->package->new( | 
| 78 |  |  |  |  |  |  | # magical =D | 
| 79 |  |  |  |  |  |  | ); | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | =head1 ATTRIBUTES | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | =head2 package | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | rw, required | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | =head2 path | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | rw, required | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | =head2 content | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | rw, required | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | =head1 AUTHOR | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | Kent Fredric <kentfredric@gmail.com> | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | This software is copyright (c) 2013 by Kent Fredric <kentfredric@gmail.com>. | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | This is free software; you can redistribute it and/or modify it under | 
| 104 |  |  |  |  |  |  | the same terms as the Perl 5 programming language system itself. | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | =cut |