NAME

Catalyst::ComponentRole::InjectionHelpers; - Common role for adaptors

SYNOPSIS

package MyApp::MySpecialAdaptor

use Moose;
with 'Catalyst::ComponentRole::InjectionHelpers';

sub ACCEPT_CONTEXT { ... }

DESCRIPTION

Common functionality and interface inforcement for injection helper adaptors. You should see Catalyst::Plugin::InjectionHelpers for more.

ATTRIBUTES

This role defines the following attributes

application

Your Catalyst application

from

A class name or coderef that is being adapted to run under Catalyst

method

The name of the method in your 'from' class that is used to create a new instance OR a coderef that is used to return an instance. Defaults to 'new'.

roles

A list of Moose::Roles to be composed into your class

transform_args

A coderef that you can use to transform configuration arguments into something more suitable for your class. For example, the configuration args is typically a hash, but your object class may require some positional arguments.

MyApp->inject_components(
  'Model::Foo' => {
    from_class = 'Foo',
    transform_args => sub {
      my ($adaptor_instance, $coderef, $app, %args) = @_;
      my $path = delete $args{path},
      return ($path, %args);
    },
  },
);

Should return the args as they as used by the initialization method of the 'from_class'.

get_config

injection_parameters

injected_component_name

TBD

METHODS

This role exposes the following public methods

merge_args

Responsible for merging global configuration and anything passed in at call time

transform_args_if_needed

Perform any programmatic argument transformation

build_new_instance

Responsible for returning a new instance of the component.

AUTHOR

John Napiorkowski email:jjnapiork@cpan.org

SEE ALSO

Catalyst::Plugin::InjectionHelpers Catalyst, Catalyst::Model::InjectionHelpers::Application, Catalyst::Model::InjectionHelpers::Factory, Catalyst::Model::InjectionHelpers::PerRequest Catalyst::ModelRole::InjectionHelpers

COPYRIGHT & LICENSE

Copyright 2016, John Napiorkowski email:jjnapiork@cpan.org

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.