1 | # ------------------------------------------------------------------------------ |
---|
2 | # (C) Crown copyright Met Office. All rights reserved. |
---|
3 | # For further details please refer to the file COPYRIGHT.txt |
---|
4 | # which you should have received as part of this distribution. |
---|
5 | # ------------------------------------------------------------------------------ |
---|
6 | |
---|
7 | use strict; |
---|
8 | use warnings; |
---|
9 | |
---|
10 | package FCM::Admin::User; |
---|
11 | |
---|
12 | use overload q{""} => \&get_name; |
---|
13 | |
---|
14 | # The default values of the attributes |
---|
15 | my %DEFAULT = ( |
---|
16 | name => undef, |
---|
17 | display_name => undef, |
---|
18 | email => undef, |
---|
19 | ); |
---|
20 | |
---|
21 | # ------------------------------------------------------------------------------ |
---|
22 | # Returns a new instance of this class. |
---|
23 | sub new { |
---|
24 | my ($class, $args_ref) = @_; |
---|
25 | return bless({%DEFAULT, %{$args_ref}}, $class); |
---|
26 | } |
---|
27 | |
---|
28 | # ------------------------------------------------------------------------------ |
---|
29 | # Getters and setters. |
---|
30 | for my $key (keys(%DEFAULT)) { |
---|
31 | no strict qw{refs}; |
---|
32 | my $getter = qq{get_$key}; |
---|
33 | my $setter = qq{set_$key}; |
---|
34 | *$getter = sub { |
---|
35 | my ($self) = @_; |
---|
36 | return $self->{$key}; |
---|
37 | }; |
---|
38 | *$setter = sub { |
---|
39 | my ($self, $value) = @_; |
---|
40 | $self->{$key} = $value; |
---|
41 | }; |
---|
42 | } |
---|
43 | |
---|
44 | 1; |
---|
45 | __END__ |
---|
46 | |
---|
47 | =head1 NAME |
---|
48 | |
---|
49 | FCM::Admin::User |
---|
50 | |
---|
51 | =head1 SYNOPSIS |
---|
52 | |
---|
53 | use FCM::Admin::User; |
---|
54 | $user = FCM::Admin::User->new({name => 'bob'}); |
---|
55 | $user->set_display_name('Robert Smith'); |
---|
56 | $user->set_email('robert.smith@somewhere.org'); |
---|
57 | |
---|
58 | =head1 DESCRIPTION |
---|
59 | |
---|
60 | An object of this class is used to store the data model of a user. |
---|
61 | |
---|
62 | =head1 METHODS |
---|
63 | |
---|
64 | =over 4 |
---|
65 | |
---|
66 | =item FCM::Admin::User->new(\%arguments) |
---|
67 | |
---|
68 | Creates a new instance. The keys of the %argument hash may contain "name", |
---|
69 | "display_name", and/or "email". |
---|
70 | |
---|
71 | =item $user->get_name() |
---|
72 | |
---|
73 | Returns the name/ID of the user. |
---|
74 | |
---|
75 | =item $user->get_display_name() |
---|
76 | |
---|
77 | Returns the display name of the user. |
---|
78 | |
---|
79 | =item $user->get_email() |
---|
80 | |
---|
81 | Returns the e-mail address of the user. |
---|
82 | |
---|
83 | =item $user->set_name($value) |
---|
84 | |
---|
85 | Sets the name/ID of the user. |
---|
86 | |
---|
87 | =item $user->set_display_name($value) |
---|
88 | |
---|
89 | Sets the display name of the user. |
---|
90 | |
---|
91 | =item $user->set_email($value) |
---|
92 | |
---|
93 | Sets the e-mail address of the user. |
---|
94 | |
---|
95 | =back |
---|
96 | |
---|
97 | =head1 COPYRIGHT |
---|
98 | |
---|
99 | E<169> Crown copyright Met Office. All rights reserved. |
---|
100 | |
---|
101 | =cut |
---|