23ec690cfcbe3cb06944ffd656f43032c966f659
[gitmo/moose-presentations.git] / moose-class / exercises / t / 06-advanced-attributes.t
1 # Your tasks ...
2 #
3 # First, we want to make the account associated with a Person a proper
4 # class. Call it BankAccount.
5 #
6 # This class should have two attributes, "balance", an Int that
7 # defaults to 100, and "owner", a Person object.
8 #
9 # The owner attribute should be a weak reference to prevent cycles.
10 #
11 # Copy the deposit and withdraw methods from the HasAccount role.
12 #
13 # Finally, add a read-only history attribute. This will be an ArrayRef
14 # of Int's. This should default to an empty array reference.
15 #
16 # Use a trigger to record the _old value_ of the balance each time it
17 # changes.
18 #
19 # Use a BUILD method in BankAccount to record the original balance in
20 # the history.
21 #
22 # We will now delete the HasAccount role entirely. Instead, add an
23 # "account" attribute to Person directly.
24 #
25 # This new account attribute should default to a new BankAccount
26 # object. Use delegation so that we can call Person->deposit and
27 # Person->withdraw and have it call those methods on the person's
28 # BankAccount object.
29 #
30 # Add a BUILD method to the Person class to set the owner of the
31 # Person's bank account to $self.
32
33 use strict;
34 use warnings;
35
36 use lib 't/lib';
37
38 use MooseClass::Tests;
39
40 use Person;
41 use Employee;
42 use BankAccount;
43
44 MooseClass::Tests::tests06();