NAME

ExtJS::Generator::DBIC::Model - ExtJS model producer

VERSION

version 0.003

SYNOPSIS

    use ExtJS::Generator::DBIC::Model;

    my $generator = ExtJS::Generator::DBIC::Model->new(
        schemaname => 'My::DBIC::Schema',
        appname    => 'MyApp',

        # defaults to $appname.model
        model_namespace => 'MyApp.model',

        # defaults to $appname.data.Model
        model_baseclass => 'MyApp.data.Model',

        #model_args => {
        #    schema => 'schemaalias',
        #},
    );

    my $extjs_model_for_foo = $generator->extjs_model('Foo');

    my @extjs_models = $generator->extjs_models;

    $generator->extjs_model_to_file( 'Foo', '/my/dir/' );

    $generator->extjs_all_to_file( '/my/dir/' );

DESCRIPTION

Creates ExtJS model classes.

At the moment only version 6 of the ExtJS framework is supported.

ATTRIBUTES

schemaname

The name of the DBIx::Class::Schema which should be used to generate the ExtJS model classes.

schema

A DBIx::Class::Schema instance, automatically instantiated from the schemaname if not specified.

appname

The ExtJS app name used as base namespace for all generated classes.

model_namespace

The ExtJS model namespace, defaults to $appname.model.

model_baseclass

The ExtJS model baseclass name from which all generated model classes should be extended.

model_args

Hashref which takes arbitrary ExtJS model attributes which are added to each generated ExtJS model class..

METHODS

extjs_model_name

Returns the ExtJS model name for a table. Should be overridden in a subclass if the default naming doesn't suit you. E.g. MyApp::Schema::Result::ARTist -> MyApp.model.Artist

extjs_model_alias

Returns the ExtJS model alias for an ExtJS model returned from "extjs_model_name". Should be overridden in a subclass if the default naming doesn't suit you. E.g. MyApp.model.Artist -> 'model.artist'

extjs_model_entityname

Returns the ExtJS model entityName for a full ExtJS classname. E.g. MyApp.model.Foo -> Foo

extjs_model

This method returns an arrayref containing the parameters that can be serialized to JavaScript and then passed to Ext.define for one DBIx::Class::ResultSource.

extjs_models

This method returns the generated ExtJS model classes as hashref indexed by their ExtJS names.

extjs_model_to_file

This method takes a single DBIx::Class::ResultSource name and a directory name and outputs the generated ExtJS model class to a file according to ExtJS naming standards. An error is thrown if the directory doesn't exist or if the file already exists.

extjs_basemodel_to_file

This method takes a directory name and outputs the generated ExtJS base model class to a file according to ExtJS naming standards.

extjs_all_to_file

This method takes a root directory name and outputs all generated ExtJS classes to a file per class according to ExtJS naming standards.

SEE ALSO

http://docs.sencha.com/extjs/6.0/6.0.0-classic/#!/api/Ext.data.Model for ExtJS model documentation.

AUTHOR

Alexander Hartmaier <abraxxa@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Alexander Hartmaier.

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