Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sort { lc($a) cmp lc($b) } @items
- package StrategyInterface;
- use Moose::Role;
- requires 'run';
- package Context;
- use Moose;
- has 'strategy' => (
- is => 'rw',
- isa => 'StrategyInterface',
- handles => [ 'run' ],
- );
- package SomeStrategy;
- use Moose;
- with 'StrategyInterface';
- sub run { warn "applying SomeStrategy!n"; }
- package AnotherStrategy;
- use Moose;
- with 'StrategyInterface';
- sub run { warn "applying AnotherStrategy!n"; }
- ###############
- package main;
- my $contextOne = Context->new(
- strategy => SomeStrategy->new()
- );
- my $contextTwo = Context->new(
- strategy => AnotherStrategy->new()
- );
- $contextOne->run();
- $contextTwo->run();
- sort { lc($a) cmp lc($b) } @items
Add Comment
Please, Sign In to add comment