File: CoinType.pm

package info (click to toggle)
libur-perl 0.470%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,192 kB
  • sloc: perl: 61,814; javascript: 255; xml: 108; sh: 13; makefile: 9
file content (28 lines) | stat: -rw-r--r-- 711 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package Vending::CoinType;

use strict;
use warnings;

use Vending;
class Vending::CoinType {
    table_name => 'coin_type',
    id_by => [
        name => { is => 'String' },
    ],
    has => [
        value_cents => { is => 'integer' },
        item_type   => { is => 'Vending::ItemType', where => [ name => \'name'] },
        type_id     => { via => 'item_type' },
    ],
    doc => 'kinds of coins the machine accepts, and their value',
    data_source => 'Vending::DataSource::CoinType',
};

# Overriding because the property definition doesn't exactly work...
sub item_type {
    my $self = shift;
    my $type_obj = Vending::ContentType->get_or_create(name => $self->name);
    return $type_obj;
}

1;