Lay the groundwork for WebGUI::Definition::Crud

This commit is contained in:
Colin Kuskie 2010-10-15 11:04:34 -07:00
parent bf8bdd1ac6
commit 2bd072311d
3 changed files with 1132 additions and 0 deletions

View file

@ -0,0 +1,87 @@
package WebGUI::Definition::Meta::Crud;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2009 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use 5.010;
use Moose::Role;
use namespace::autoclean;
use WebGUI::Definition::Meta::Property;
use WebGUI::Definition::Meta::Property::Asset;
no warnings qw(uninitialized);
with 'WebGUI::Definition::Meta::Class';
our $VERSION = '0.0.1';
=head1 NAME
Package WebGUI::Definition::Meta::Shop
=head1 DESCRIPTION
Extends 'WebGUI::Definition::Meta::Class' to provide attributes specific to Assets.
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 property_meta ( )
Asset Definitions use WebGUI::Definition::Meta::Property::Asset as the base class
for properties.
=cut
has 'property_metaroles' => (
is => 'ro',
default => sub { [ 'WebGUI::Definition::Meta::Property', 'WebGUI::Definition::Meta::Property::Crud'] },
);
#-------------------------------------------------------------------
has [ qw{tableName tableKey sequenceKey} ] => (
is => 'rw',
);
#-------------------------------------------------------------------
=head2 tableName ( )
The table that this plugin stores its properties in.
=cut
#-------------------------------------------------------------------
=head2 tableKey ( )
The column in the table that is the primary key.
=cut
#-------------------------------------------------------------------
=head2 sequenceKey ( )
The column in the table that denotes the order of objects in the table. If undef, or empty,
then no ordering is possible.
=cut
1;

View file

@ -0,0 +1,73 @@
package WebGUI::Definition::Meta::Property::Asset;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2009 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use 5.010;
use Moose::Role;
use namespace::autoclean;
no warnings qw(uninitialized);
our $VERSION = '0.0.1';
=head1 NAME
Package WebGUI::Definition::Meta::Property::Asset
=head1 DESCRIPTION
Extends WebGUI::Definition::Meta::Property to provide Asset properties with
specific methods. The tableName and fieldType class properties must be defined.
=head1 METHODS
The following methods are added.
=cut
has 'serialize' => (
is => 'ro',
);
has 'isQueryKey' => (
is => 'ro',
);
#-------------------------------------------------------------------
=head2 serialize ( )
serialize tells WebGUI::Crud to automatically serialize this field in a JSON wrapper before storing it to the database, and to convert it back to it's native structure upon retrieving it from the database. This is useful if you wish to persist hash references or array references.
=cut
#-------------------------------------------------------------------
=head2 isQueryKey ( )
isQueryKey tells WebGUI::Crud that the field should be marked as 'non null' in the table and then adds an index of the same name to the table to make searching on the field faster. B<WARNING:> Don't use this if the field is already a sequenceKey. If it's a sequence key then it will automatically be indexed.
=cut
#-------------------------------------------------------------------
=head2 noFormPost ( )
This is boolean which indicates that no data from HTML forms should be validated
and stored for this property.
=cut
1;