Name
Web::Components::Loader - Loads and instantiates MVC components
Synopsis
package Component::Server;
use Plack::Builder;
use Web::Simple;
with 'Web::Components::Loader';
Description
Loads and instantiates MVC components. Searches the namespaces; Controller
, Model
, and View
in the consuming classes library root. Any components found are loaded and instantiated
The component collection references are passed to the component constructors so that a component can discover any dependent components. The collection references are not fully populated when the component is instantiated so attributes that default to component references should be marked as lazy
Configuration and Environment
This role requires config
and log
methods in the consuming class
Defines the following attributes;
factory_args
-
A code reference used to instantiate the request factory
controllers
-
An array reference of controller object reference sorted into
moniker
order models
-
A hash reference of model object references
views
-
A hash reference of view object references
Subroutines/Methods
dispatch_request
-
Installs a response filter that processes and renders the responses from the controller methods
Controller responses that do not match the expected signature are allowed to bubble up
The expected controller return value signature is;
[ 'model_moniker/method_name', @web_simple_request_parameters ]
The Web::Simple request parameters are used to instantiate an instance of Web::ComposableRequest::Base
The specified method on the model select by the moniker is called passing the request object in. A hash references, the stash, is the expected response and this is passed along with the request object into the view which renders the response
Array references, a Plack response, are allowed to bubble up and bypass the call to the view
If the stash contains a redirect attribute then a redirect response is generated. Any message intended to be viewed by the user is stored in the session and is retrieved by the next request
Diagnostics
None
Dependencies
Incompatibilities
There are no known incompatibilities in this module
Bugs and Limitations
There are no known bugs in this module. Please report problems to http://rt.cpan.org/NoAuth/Bugs.html?Dist=Web-Components. Patches are welcome
Acknowledgements
Larry Wall - For the Perl programming language
Author
Peter Flanigan, <pjfl@cpan.org>
License and Copyright
Copyright (c) 2017 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE