[Bps-public-commit] r12477 - in Prophet/branches/moose: .
sartak at bestpractical.com
sartak at bestpractical.com
Sat May 17 08:07:26 EDT 2008
Author: sartak
Date: Sat May 17 08:07:24 2008
New Revision: 12477
Modified:
Prophet/branches/moose/ (props changed)
Prophet/branches/moose/Makefile.PL
Prophet/branches/moose/lib/Prophet/Record.pm
Log:
r56221 at onn: sartak | 2008-05-17 08:07:08 -0400
Moosify Prophet::Record, new dependency on MooseX::ClassAttribute (which fills the same niche as Class::Data::Inheritable)
Modified: Prophet/branches/moose/Makefile.PL
==============================================================================
--- Prophet/branches/moose/Makefile.PL (original)
+++ Prophet/branches/moose/Makefile.PL Sat May 17 08:07:24 2008
@@ -26,6 +26,7 @@
requires('Scalar::Defer');
requires('Moose'); # Moose::Util::TypeConstraints
requires('MooseX::AttributeHelpers');
+requires('MooseX::ClassAttribute');
features(
'REST Server' => [
Modified: Prophet/branches/moose/lib/Prophet/Record.pm
==============================================================================
--- Prophet/branches/moose/lib/Prophet/Record.pm (original)
+++ Prophet/branches/moose/lib/Prophet/Record.pm Sat May 17 08:07:24 2008
@@ -1,7 +1,12 @@
-use warnings;
-use strict;
-
package Prophet::Record;
+use Moose;
+use MooseX::ClassAttribute;
+use Params::Validate;
+use Data::UUID;
+use List::MoreUtils qw/uniq/;
+use Prophet::App; # for require_module. Kinda hacky
+
+use constant collection_class => 'Prophet::Collection';
=head1 NAME
@@ -13,24 +18,45 @@
=cut
-use base qw'Class::Accessor Class::Data::Inheritable';
-
-__PACKAGE__->mk_accessors(qw'handle uuid type');
-__PACKAGE__->mk_classdata( REFERENCES => {} );
-__PACKAGE__->mk_classdata( PROPERTIES => {} );
+has handle => (
+ is => 'rw',
+ required => 1,
+);
+
+has type => (
+ is => 'rw',
+ isa => 'Str',
+ required => 1,
+ default => sub {
+ my $self = shift;
+ $self->record_type;
+ },
+);
+
+has uuid => (
+ is => 'rw',
+ isa => 'Str',
+);
+
+class_has REFERENCES => (
+ is => 'rw',
+ isa => 'HashRef',
+ default => sub { {} },
+);
+
+class_has PROPERTIES => (
+ is => 'rw',
+ isa => 'HashRef',
+ default => sub { {} },
+);
sub declared_props {
return sort keys %{ $_[0]->PROPERTIES };
}
-use Params::Validate;
-use Data::UUID;
-use List::MoreUtils qw/uniq/;
-use Prophet::App; # for require_module. Kinda hacky
-
my $UUIDGEN = Data::UUID->new();
-use constant collection_class => 'Prophet::Collection';
+sub record_type { $_[0]->type }
=head1 METHODS
@@ -40,18 +66,6 @@
=cut
-sub new {
- my $class = shift;
- my $self = bless {}, $class;
- my $args = ref( $_[0] ) ? $_[0] : {@_};
- $args->{type} ||= $class->record_type;
- my %args = validate( @{ [%$args] }, { handle => 1, type => 1 } );
- $self->$_( $args{$_} ) for keys(%args);
- return $self;
-}
-
-sub record_type { $_[0]->type }
-
=head2 register_reference
=cut
@@ -282,4 +296,8 @@
}
+__PACKAGE__->meta->make_immutable;
+no Moose;
+no MooseX::ClassAttribute;
+
1;
More information about the Bps-public-commit
mailing list