| 1 | package Nitesi::Inventory; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Moo::Role; | ||
| 7 | use Sub::Quote; | ||
| 8 | |||
| 9 | =head1 NAME | ||
| 10 | |||
| 11 | Nitesi::Inventory - Inventory class for Nitesi Shop Machine | ||
| 12 | |||
| 13 | =head1 ATTRIBUTES | ||
| 14 | |||
| 15 | =head2 quantity | ||
| 16 | |||
| 17 | Number of available products. | ||
| 18 | |||
| 19 | =cut | ||
| 20 | |||
| 21 | has quantity => ( | ||
| 22 | is => 'rw', | ||
| 23 | lazy => 1, | ||
| 24 | default => quote_sub q{return 0;}, | ||
| 25 | ); | ||
| 26 | |||
| 27 | =head2 in_stock | ||
| 28 | |||
| 29 | Whether to show product as in stock or not. | ||
| 30 | |||
| 31 | =cut | ||
| 32 | |||
| 33 | has in_stock => ( | ||
| 34 | is => 'rw', | ||
| 35 | ); | ||
| 36 | |||
| 37 | =head1 METHODS | ||
| 38 | |||
| 39 | =head2 inventory_api_info | ||
| 40 | |||
| 41 | API information for inventory class. | ||
| 42 | |||
| 43 | =cut | ||
| 44 | |||
| 45 | sub inventory_api_info { | ||
| 46 | my $self = shift; | ||
| 47 | |||
| 48 | return {table => 'inventory', | ||
| 49 | key => 'sku', | ||
| 50 | sparse => 1, | ||
| 51 | }; | ||
| 52 | } | ||
| 53 | |||
| 54 | =head1 AUTHOR | ||
| 55 | |||
| 56 | Stefan Hornburg (Racke), <racke@linuxia.de> | ||
| 57 | |||
| 58 | =head1 LICENSE AND COPYRIGHT | ||
| 59 | |||
| 60 | Copyright 2012-2013 Stefan Hornburg (Racke) <racke@linuxia.de>. | ||
| 61 | |||
| 62 | This program is free software; you can redistribute it and/or modify it | ||
| 63 | under the terms of either: the GNU General Public License as published | ||
| 64 | by the Free Software Foundation; or the Artistic License. | ||
| 65 | |||
| 66 | See http://dev.perl.org/licenses/ for more information. | ||
| 67 | |||
| 68 | =cut | ||
| 69 | |||
| 70 | 1; |