Reaction::InterfaceModel::Reflector::DBIC - Automatically Generate InterfaceModels from DBIx::Class models
The InterfaceModel reflectors are classes that are meant to aid you in easily generating Reaction::InterfaceModel classes that represent their underlying DBIx::Class domain models by introspecting your DBIx::Class::ResultSources and creating a collection of Reaction::InterfaceModel::Object and Reaction::InterfaceModel::Collection classes for you to use.
The default base class of all Object classes will be Reaction::InterfaceModel::Object and the default Collection type will be Reaction::InterfaceModel::Collection::Virtual::ResultSet.
Additionally, the reflector can create InterfaceModel actions that interact with the supplied Reaction::UI::Controller::Collection::CRUD, allowing you to easily set up a highly customizable CRUD interface in minimal time.
At this time, supported collection actions consist of:
Creates a new item in the collection and underlying ResultSet.
Deletes all the items in a collection and it's underlying resultset using delete_all
delete_all
And supported object actions are :
Updates an existing object.
Deletes an existing object.
package MyApp::IM::TestModel; use base 'Reaction::InterfaceModel::Object'; use Reaction::Class; use Reaction::InterfaceModel::Reflector::DBIC; my $reflector = Reaction::InterfaceModel::Reflector::DBIC->new; #Reflect everything $reflector->reflect_schema ( model_class => __PACKAGE__, schema_class => 'MyApp::Schema', );
#reflect everything except for the FooBar and FooBaz classes $reflector->reflect_schema ( model_class => __PACKAGE__, schema_class => 'MyApp::Schema', sources => [-exclude => [qw/FooBar FooBaz/] ], # you could also do: sources => [-exclude => qr/(?:FooBar|FooBaz)/, # or even sources => [-exclude => [qr/FooBar/, qr/FooBaz/], ); #reflect only the Foo family of sources $reflector->reflect_schema ( model_class => __PACKAGE__, schema_class => 'MyApp::Schema', sources => qr/^Foo/, );
#Reflect Foo and Baz in their entirety and exclude the field 'avatar' in the Bar ResultSource $reflector->reflect_schema ( model_class => __PACKAGE__, schema_class => 'MyApp::Schema', sources => [qw/Foo Baz/, [ Bar => {attributes => [[-exclude => 'avatar']] } ], # or exclude by regex [ Bar => {attributes => [-exclude => qr/avatar/] } ], # or simply do not include it... [ Bar => {attributes => [qw/id name description/] } ], ], );
Allow the reflector to dump the generated code out as files, eliminating the need to reflect on startup every time. This will likely take quite a bit of work though. The main work is already in place, but the grunt work is still left. At the moment there is no closures that can't be dumped out as code with a little bit of work.
See Reaction::Class for authors.
See Reaction::Class for the license.
To install Reaction, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Reaction
CPAN shell
perl -MCPAN -e shell install Reaction
For more information on module installation, please visit the detailed CPAN module installation guide.