File Coverage

blib/lib/Elastic/Model/Deleted.pm
Criterion Covered Total %
statement 15 20 75.0
branch n/a
condition n/a
subroutine 5 9 55.5
pod 1 1 100.0
total 21 30 70.0


line stmt bran cond sub pod time code
1             package Elastic::Model::Deleted;
2             $Elastic::Model::Deleted::VERSION = '0.52';
3 23     23   138 use Moose;
  23         47  
  23         270  
4 23     23   154051 use strict;
  23         62  
  23         540  
5 23     23   127 use warnings;
  23         50  
  23         724  
6 23     23   123 use Carp;
  23         48  
  23         1696  
7 23     23   135 use namespace::autoclean;
  23         47  
  23         253  
8              
9             #===================================
10             has 'uid' => (
11             #===================================
12                 is => 'ro',
13                 isa => 'Elastic::Model::UID',
14                 required => 1,
15             );
16              
17             #===================================
18 0     0     sub _can_inflate {0}
19       0     sub _inflate_doc { }
20 0     0 1   sub has_been_deleted {1}
21             #===================================
22              
23             our $AUTOLOAD;
24              
25             #===================================
26             sub AUTOLOAD {
27             #===================================
28 0     0         my $self = shift;
29 0               my $uid = $self->uid;
30 0               croak
31                     sprintf(
32                     "Object type (%s) with ID (%s) in index (%s) has been deleted",
33                     $uid->type, $uid->id, $uid->index );
34             }
35              
36             __PACKAGE__->meta->make_immutable;
37              
38             1;
39              
40             =pod
41            
42             =encoding UTF-8
43            
44             =head1 NAME
45            
46             Elastic::Model::Deleted - A class to represent deleted doc objects which are still in scope
47            
48             =head1 VERSION
49            
50             version 0.52
51            
52             =head1 DESCRIPTION
53            
54             When an object in scope is deleted, it is reblessed into
55             Elastic::Model::Deleted, which throws an error if any method other than
56             those listed below are called.
57            
58             For instance:
59            
60             $user = $domain->get( user => 1 );
61             $user->delete;
62             print $user->name;
63             # throws error
64            
65             =head1 ATTRIBUTES
66            
67             =head2 uid
68            
69             $uid = $deleted_doc->uid
70            
71             The original UID of the deleted doc.
72            
73             =head1 METHODS
74            
75             =head2 has_been_deleted()
76            
77             1 == $deleted->has_been_deleted()
78            
79             Returns true without checking Elasticsearch. This method is provided
80             so that it can be called in an L<Elastic::Model::Role::Doc/on_conflict>
81             handler.
82            
83             Also see L<Elastic::Model::Role::Doc/has_been_deleted()>.
84            
85             =head1 AUTHOR
86            
87             Clinton Gormley <drtech@cpan.org>
88            
89             =head1 COPYRIGHT AND LICENSE
90            
91             This software is copyright (c) 2015 by Clinton Gormley.
92            
93             This is free software; you can redistribute it and/or modify it under
94             the same terms as the Perl 5 programming language system itself.
95            
96             =cut
97              
98             __END__
99            
100             # ABSTRACT: A class to represent deleted doc objects which are still in scope
101            
102