Skip to content

Instantly share code, notes, and snippets.

@rsrchboy
Created October 9, 2012 21:13
Show Gist options
  • Save rsrchboy/3861480 to your computer and use it in GitHub Desktop.
Save rsrchboy/3861480 to your computer and use it in GitHub Desktop.
painless "creating methods" via config
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