File: ConfigureSlot.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 (34 lines) | stat: -rw-r--r-- 856 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
29
30
31
32
33
34
package Vending::Command::Service::ConfigureSlot;
use strict;
use warnings;
use Vending;

class Vending::Command::Service::ConfigureSlot {
    is => 'Vending::Command::Service',
    has => [
        name => { is => 'String', doc => 'Slot name' },
        label => { is => 'String', doc => 'New label for the slot', is_optional => 1 },
        cost_cents => { is => 'String', doc => 'New price for this slot', is_optional => 1 },
    ],
};

sub execute {
    my $self = shift;

    my $machine = $self->machine();
    my $loc = $machine->machine_locations(name => $self->name);
    unless ($loc) {
        $self->error_message("Not a valid slot name");
        return;
    }

    if (defined $self->label) {
        $loc->label($self->label);
    }
    if (defined $self->cost_cents) {
        $loc->cost_cents($self->cost_cents);
    }
    return 1;
}
1;