SweetPea::Application::Model - Model support for SweetPea-Application.


SweetPea-Application documentation Contained in the SweetPea-Application distribution.

Index


Code Index:

NAME

Top

SweetPea::Application::Model - Model support for SweetPea-Application.

SYNOPSIS

Top

    ... from inside SweetPea::Application or a Controller;
    #access Model::Users::create_account()
    $s->model('Users')->create_account();

METHODS

Top

new

    The new method instantiates a new SweetPea::Application::Model object
    which loads model packages on requests ands provides accessors to it's
    functions. 

    $s->plug( 'model', sub { return SweetPea::Application::Model->new($s); });

AUTHOR

Top

Al Newkirk, <al.newkirk at awnstudio.com>


SweetPea-Application documentation Contained in the SweetPea-Application distribution.
package SweetPea::Application::Model;

use warnings;
use strict;

our $VERSION = '0.001';

sub new {
    my ($class, $s, $model) = @_;
    my $self        = {};
    my $pckg        = $model;
    bless $self, $class;
    $model          =~ s/^\///;
    $pckg           =~ s/[\\\:]/\//g;
    $pckg           = 'Model::' . $model;
    $model          = 'Model/' . $model . '.pm';
    
    require $model;
    return  $pckg->new($s);
}

1; # End of SweetPea::Application::Model