Created
October 9, 2012 21:13
-
-
Save rsrchboy/3861480 to your computer and use it in GitHub Desktop.
painless "creating methods" via config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Moose; | |
use namespace::autoclean; | |
use MooseX::Shortcuts 0.015; | |
# ... | |
has routing_logic => ( | |
traits => ['Code'], | |
is => 'lazy', | |
isa => 'CodeRef', | |
builder => sub { .... App::Config fetch ... }, | |
handles => { | |
# just call the coderef: $ref->() | |
route_to => 'execute', | |
# or call it as a method on the instance: $self->$ref() | |
route_to => 'execute_method', | |
}, | |
); | |
# ... later; calls the coderef from App::Config | |
my $route = $self->route_to; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment