Finished slides & exercises for section 4 (method modifiers)
[gitmo/moose-presentations.git] / moose-class / exercises / t / 04-method-modifiers.t
1 # Your tasks ...
2 #
3 # You are going to make our Person and Employee classes capable of
4 # outputting an XML document describing the object.
5 #
6 # The document will contain a tag and value for each attribute.
7 #
8 # You will use method modifiers and roles to achieve this.
9 #
10 # Start by creating a new role, OutputsXML.
11 #
12 # This role should require an "as_xml" method in the classes which
13 # consume it.
14 #
15 # This role should also use an around modifier on the as_xml method in
16 # order to make sure the document is well-formed XML.
17 #
18 # This document will look something like this:
19 #
20 # <?xml version="1.0" encoding="UTF-8"?>
21 # <Person>
22 # <first_name>Joe</first_name>
23 # <last_name>Smith</last_name>
24 # </Person>
25 #
26 # Use the role to create the xml declaration (the first line) and the
27 # container tags (<person> or <employee)
28 #
29 # The classes should return a list strings. Each string should be a
30 # tagged value for an attribute. For consistency, return the
31 # attributes in sorted order.
32 #
33 # ( '<first_name>Joe</first_name>', '<last_name>Smith</last_name>' )
34 #
35 # If an attribute is empty, just output an empty tag (<foo></foo>).
36 #
37 # Use an augment modifier in the Person and Employee classes to allow
38 # Employee to return just its own attributes.
39
40 use strict;
41 use warnings;
42
43 use lib 't/lib';
44
45 use MooseClass::Tests;
46
47 use Person;
48 use Employee;
49
50 MooseClass::Tests::tests04();