| 1 | package App::MultiModule::Tasks::MongoDB; | ||
| 2 | $App::MultiModule::Tasks::MongoDB::VERSION = '1.142810'; | ||
| 3 | |||
| 4 | 1 | ▶ | use 5.006; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use warnings FATAL => 'all'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use Message::MongoDB; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use Data::Dumper; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 1 | ▶ | use Storable; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 1 | ▶ | use parent 'App::MultiModule::Task'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | =head1 NAME | ||
| 13 | |||
| 14 | App::MultiModule::Tasks::MongoDB - File following task for App::MultiModule | ||
| 15 | |||
| 16 | =cut | ||
| 17 | |||
| 18 | =head2 message | ||
| 19 | |||
| 20 | =cut | ||
| 21 | |||
| 22 | sub message { | ||
| 23 | my $self = shift; | ||
| 24 | my $message = shift; | ||
| 25 | $message = Storable::dclone($message); | ||
| 26 | delete $message->{'.ipc_transit_meta'}; | ||
| 27 | my $method = $message->{mongo_method} || 'update'; | ||
| 28 | my $mongo = $self->{mongo}; | ||
| 29 | my $mongo_write = $message; | ||
| 30 | my %args = ( | ||
| 31 | mongo_db => $message->{mongo_db}, | ||
| 32 | mongo_collection => $message->{mongo_collection}, | ||
| 33 | mongo_method => $method, | ||
| 34 | mongo_search => $message->{mongo_search}, | ||
| 35 | mongo_write => $message | ||
| 36 | ); | ||
| 37 | $mongo->message(\%args); | ||
| 38 | } | ||
| 39 | |||
| 40 | =head2 set_config | ||
| 41 | |||
| 42 | =cut | ||
| 43 | sub set_config { | ||
| 44 | my $self = shift; | ||
| 45 | my $config = shift; | ||
| 46 | $self->{config} = $config; | ||
| 47 | $self->{mongo} = Message::MongoDB->new() unless $self->{mongo}; | ||
| 48 | } | ||
| 49 | |||
| 50 | =head1 AUTHOR | ||
| 51 | |||
| 52 | Dana M. Diederich, C<< <dana@realms.org> >> | ||
| 53 | |||
| 54 | =head1 BUGS | ||
| 55 | |||
| 56 | Please report any bugs or feature requests through L<https://github.com/dana/App-MultiModule-Tasks-MongoDB/issues>. I will be notified, and then you'll | ||
| 57 | automatically be notified of progress on your bug as I make changes. | ||
| 58 | |||
| 59 | =head1 SUPPORT | ||
| 60 | |||
| 61 | You can find documentation for this module with the perldoc command. | ||
| 62 | perldoc App::MultiModule::Tasks::MongoDB | ||
| 63 | |||
| 64 | |||
| 65 | You can also look for information at: | ||
| 66 | |||
| 67 | =over 4 | ||
| 68 | |||
| 69 | =item * Report bugs here: | ||
| 70 | |||
| 71 | L<https://github.com/dana/App-MultiModule-Tasks-MongoDB/issues> | ||
| 72 | |||
| 73 | =item * AnnoCPAN: Annotated CPAN documentation | ||
| 74 | |||
| 75 | L<http://annocpan.org/dist/App-MultiModule-Tasks-MongoDB> | ||
| 76 | |||
| 77 | =item * CPAN Ratings | ||
| 78 | |||
| 79 | L<http://cpanratings.perl.org/d/App-MultiModule-Tasks-MongoDB> | ||
| 80 | |||
| 81 | =item * Search CPAN | ||
| 82 | L<https://metacpan.org/module/App::MultiModule::Tasks::MongoDB> | ||
| 83 | |||
| 84 | =back | ||
| 85 | |||
| 86 | =head1 ACKNOWLEDGEMENTS | ||
| 87 | |||
| 88 | =head1 LICENSE AND COPYRIGHT | ||
| 89 | |||
| 90 | Copyright 2014 Dana M. Diederich. | ||
| 91 | |||
| 92 | This program is free software; you can redistribute it and/or modify it | ||
| 93 | under the terms of the the Artistic License (2.0). You may obtain a | ||
| 94 | copy of the full license at: | ||
| 95 | |||
| 96 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||
| 97 | |||
| 98 | Any use, modification, and distribution of the Standard or Modified | ||
| 99 | Versions is governed by this Artistic License. By using, modifying or | ||
| 100 | distributing the Package, you accept this license. Do not use, modify, | ||
| 101 | or distribute the Package, if you do not accept this license. | ||
| 102 | |||
| 103 | If your Modified Version has been derived from a Modified Version made | ||
| 104 | by someone other than you, you are nevertheless required to ensure that | ||
| 105 | your Modified Version complies with the requirements of this license. | ||
| 106 | |||
| 107 | This license does not grant you the right to use any trademark, service | ||
| 108 | mark, tradename, or logo of the Copyright Holder. | ||
| 109 | |||
| 110 | This license includes the non-exclusive, worldwide, free-of-charge | ||
| 111 | patent license to make, have made, use, offer to sell, sell, import and | ||
| 112 | otherwise transfer the Package with respect to any patent claims | ||
| 113 | licensable by the Copyright Holder that are necessarily infringed by the | ||
| 114 | Package. If you institute patent litigation (including a cross-claim or | ||
| 115 | counterclaim) against any party alleging that the Package constitutes | ||
| 116 | direct or contributory patent infringement, then this Artistic License | ||
| 117 | to you shall terminate on the date that such litigation is filed. | ||
| 118 | |||
| 119 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER | ||
| 120 | AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. | ||
| 121 | THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
| 122 | PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY | ||
| 123 | YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR | ||
| 124 | CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR | ||
| 125 | CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, | ||
| 126 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 127 | |||
| 128 | |||
| 129 | =cut | ||
| 130 | |||
| 131 | 1; # End of App::MultiModule::Tasks::MongoDB | ||
| 132 | |||