From 882317c2c9b0298fae6643ccfd3dbe5d98cd0437 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 10 Nov 2010 09:58:08 -0800 Subject: [PATCH] Convert ThingyRecord over to Moose. --- .../Sku/ThingyRecord/Record.pm | 86 +++++++++---------- 1 file changed, 40 insertions(+), 46 deletions(-) diff --git a/lib/WebGUI/AssetCollateral/Sku/ThingyRecord/Record.pm b/lib/WebGUI/AssetCollateral/Sku/ThingyRecord/Record.pm index 94f7d42f9..8b3960e84 100644 --- a/lib/WebGUI/AssetCollateral/Sku/ThingyRecord/Record.pm +++ b/lib/WebGUI/AssetCollateral/Sku/ThingyRecord/Record.pm @@ -34,51 +34,45 @@ for a list of base methods that are available. =cut -use base 'WebGUI::Crud'; - -#---------------------------------------------------------------- - -=head2 crud_definition ($session) - -Defintion subroutine to set up CRUD. - -=cut - -sub crud_definition { - my ($class, $session) = @_; - my $definition = $class->SUPER::crud_definition($session); - $definition->{tableName} = 'ThingyRecord_record'; - $definition->{tableKey} = 'recordId'; - my $properties = $definition->{properties}; - $properties->{transactionId} = { - fieldType => "hidden", - defaultValue => undef, - }; - $properties->{assetId} = { - fieldType => "hidden", - defaultValue => undef, - }; - $properties->{expires} = { - fieldType => "DateTime", - defaultValue => 0, - }; - $properties->{userId} = { - fieldType => "hidden", - defaultValue => undef, - }; - $properties->{fields} = { - fieldType => 'textarea', - defaultValue => '', - }; - $properties->{isHidden} = { - fieldType => 'yesNo', - defaultValue => 0, - }; - $properties->{sentExpiresNotice} = { - fieldType => 'yesNo', - defaultValue => 0, - }; - return $definition; -} +use Moose; +use WebGUI::Definition::Crud; +extends 'WebGUI::Crud'; +define tableName => 'ThingyRecord_record'; +define tableKey => 'recordId'; +has recordId => ( + required => 1, + is => 'ro', +); +property transactionId => ( + label => 'transactionId', + fieldType => "hidden", +); +property assetId => ( + label => 'assetId', + fieldType => "hidden", +); +property expires => ( + label => 'expires', + fieldType => "DateTime", +); +property userId => ( + label => 'userId', + fieldType => "hidden", +); +property fields => ( + label => 'fields', + fieldType => 'textarea', + default => '', +); +property isHidden => ( + label => 'isHidden', + fieldType => 'yesNo', + default => 0, +); +property sentExpiresNotice => ( + label => 'sentExpiresNotice', + fieldType => 'yesNo', + default => 0, +); 1;