1 package App::IdiotBox::Video;
5 sub fields { return qw(slug bucket_slug name author details announcement_id) }
7 with 'App::IdiotBox::Clonable';
9 sub announcement_id { shift->{announcement_id} }
10 sub bucket_slug { shift->{bucket_slug} }
11 sub slug { shift->{slug} }
12 sub name { shift->{name} }
13 sub author { shift->{author} }
14 sub details { shift->{details} }
15 sub bucket { shift->{bucket} }
17 (my $s = join(' ', @{+shift}{qw(author name)})) =~ s/ /-/g;
21 join('/', $_[0]->bucket->slug, $_[0]->slug);
25 my ($self, %args) = @_;
27 my %update = map { $_ => delete $args{$_} } grep { exists $args{$_} } $self->fields;
30 return (undef, "Unknown fields in update: " . join(',', keys %args));
34 return (undef, "No changes requested");
37 for my $k (qw(slug bucket_slug name author details)) {
40 if (exists $update{$k} && $update{$k} =~ /^\s+$/) {
44 return (undef, "Empty fields in update: ", join(',', @bad)) if @bad;
47 for my $k (qw(slug bucket_slug)) {
48 $update{$k} =~ s/\s+/-/g if exists $update{$k};
51 my $new = $self->clone;
53 $new->{$_} = $update{$_} for keys %update;