epic-ts
[kivitendo-erp.git] / SL / Clipboard / RequirementSpecPicture.pm
1 package SL::Clipboard::RequirementSpecPicture;
2
3 use strict;
4
5 use parent qw(SL::Clipboard::Base);
6
7 use SL::Common;
8 use SL::Locale::String;
9 use MIME::Base64;
10
11 sub dump {
12   my ($self, $object) = @_;
13
14   $self->reload_object($object);
15
16   my $tree    = $self->as_tree($object, exclude => sub { ref($_[0]) !~ m/::RequirementSpecPicture$/ });
17   $tree->{$_} = encode_base64($tree->{$_}, '') for $self->_binary_column_names('SL::DB::RequirementSpecPicture');
18
19   return $tree;
20 }
21
22 sub describe {
23   my ($self) = @_;
24
25   return t8('Requirement spec picture "#1"', $self->content->{description} ? $self->content->{description} . ' (' . $self->content->{picture_file_name} . ')' : $self->content->{picture_file_name});
26 }
27
28 sub _fix_object {
29   my ($self, $object) = @_;
30
31   $object->$_(undef) for qw(number);
32   $object->$_(decode_base64($object->$_)) for $self->_binary_column_names('SL::DB::RequirementSpecPicture');
33
34   return $object;
35 }
36
37 1;
38 __END__
39
40 =pod
41
42 =encoding utf8
43
44 =head1 NAME
45
46 SL::Clipboard::RequirementSpecPicture - Clipboard specialization for
47 SL::DB::RequirementSpecPicture
48
49 =head1 NOTES
50
51 The underlying RDBO model contains binary columns, but binary data
52 cannot be dumped as YAML. Therefore the binary content is encoded in
53 Base64 in L</dump> and decoded back to binary form in L</_fix_object>.
54
55 =head1 FUNCTIONS
56
57 =over 4
58
59 =item C<describe>
60
61 Returns a human-readable description including the title and an
62 excerpt of its content.
63
64 =item C<dump $object>
65
66 This specialization reloads C<$object> from the database, and dumps
67 it. Binary columns are dumped encoded in Base64.
68
69 =item C<_fix_object $object>
70
71 Fixes C<$object> by clearing certain columns like the number. Also
72 decodes binary columns from Base64 back to binary.
73
74 =back
75
76 =head1 BUGS
77
78 Nothing here yet.
79
80 =head1 AUTHOR
81
82 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
83
84 =cut