= Intro (30 minutes) * concepts (ala Moose::Manual::Concepts) = Classes * Making a class use Moose * extends * overrides/super * trivial attributes ** has 'foo' => ( is => ... ) (ro & rw) ** no other attribute features yet * "no Moose" * Immutability == Exercises * Build a Person class that uses Moose ** first_name ** last_name ** assume both attributes are always provided * build an Employee class that is a subclass of Person ** job_title = Roles * Making a role * roles as interfaces * requires * consuming roles in classes * consuming roles in roles * "no Moose::Role" == Exercises * build a role for Human * make the Person class consume the role * make the role require a "full_name" method * implement this method for Person * override it for Employee to include their title = Basic attributes * required * default & builder * lazy * predicate, clearer * init_arg * reader & writer * attribute inheritance * MX attribute naming modules == Exercises * Go back to Person class ** make first & last name required * Go back to Employee ** make title default to "Worker" ** add predicate & clearer for title ** add salary_level attribute, number from 1-10 ** salary, lazy default of salary_level * 1,000, init_arg is undef = Method modifiers * before/after ** before for state validation ** after for additional state changes * around ** modifying arguments & return values * method modifiers in roles ** requiring the wrapped method * augment/inner == Exercises = Types * built-in types * parameterizable types * declaring subtypes ** URI ** Email ** class names & role names * coercions * duck_type * attribute isa & does * attribute coerce => 1 * MX::Types == Exercises * Add sane types to all existing attributes in Person, Employee, roles * Add an email attribute. Make a new email type that does some minimal validate like /[^@]+\@[\w\-]+(?:\.[\w\-]+)+/ = Advanced attributes * weak_ref * triggers * delegation * metaclass & traits == Exercises * Make the bank account a proper object and delegate to it for deposit & withdraw * Add an overdraft account like in the cookbook * Make the overdraft account link bank to accounts which link to it as a weak_ref * metaclass & traits? = Introspection * List of attributes for a class ** attribute options ** associated methods * List of methods for a class ** associated attributes ** check original_package for source of method (did it come from a role?) ** $method->isa(...) to determine if it's wrapped/augmented/overridden * List of parent classes, subclasses = Tour of MooseX * MX::AH ** delegation for Perl built-ins ** private accessor with public provides (_options as the attribute, get_option, set_option, options_list) ** lazy default of an empty reference * ::StrictConstructor * ::Getopt * ::Clone * ::Declare * ::Workers ? * ::NonMoose * ::Singleton * ::ClassAttribute = Writing a MooseX Module == Exercises