/[Frey]/trunk/lib/Frey/ClassLoader.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/ClassLoader.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 457 by dpavlin, Wed Nov 19 16:53:13 2008 UTC revision 653 by dpavlin, Sun Nov 30 23:49:32 2008 UTC
# Line 8  Load L<Frey> classes Line 8  Load L<Frey> classes
8  =cut  =cut
9    
10  extends 'Frey';  extends 'Frey';
11    with 'Frey::Session';
12    
13  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
14  use File::Find;  use File::Find;
# Line 34  sub classes { Line 35  sub classes {
35                  $class =~ s{^lib/}{};                  $class =~ s{^lib/}{};
36                  $class =~ s{\.pm$}{};                  $class =~ s{\.pm$}{};
37                  $class =~ s{/}{::}g;                  $class =~ s{/}{::}g;
38                    if ( $class =~ m{Mojo} ) {
39                            $self->TODO( "Mojo support" );
40                            return;
41                    }
42                  $class_path->{ $class } = $_;                  $class_path->{ $class } = $_;
43          } }, 'lib');          } }, 'lib');
44          warn "## class_path = ",dump( $class_path ) if $self->debug;          warn "## class_path = ",dump( $class_path ) if $self->debug;
# Line 163  sub class_methods { Line 168  sub class_methods {
168    
169  sub class_runnable {  sub class_runnable {
170          my ( $self, $class ) = @_;          my ( $self, $class ) = @_;
171          my @methods = grep { m{^as_} } $self->class_methods( $class );          my @methods = grep { m{^as_} || m{_as_} } $self->class_methods( $class );
172          return @methods if wantarray;          return @methods if wantarray;
173          return \@methods;          return \@methods;
174  }  }
# Line 197  It is used by L<Frey::Run> and L<Frey::P Line 202  It is used by L<Frey::Run> and L<Frey::P
202                  $self->data;                  $self->data;
203          }          }
204    
205          package Frey::Role::as_data;          package Frey::Role::as_sponge;
206          use Moose::Role;          use Moose::Role;
207          sub as_sponge {          sub as_sponge {
208                  my ($self) = @_;                  my ($self) = @_;
# Line 207  It is used by L<Frey::Run> and L<Frey::P Line 212  It is used by L<Frey::Run> and L<Frey::P
212    
213  sub new_frey_class {  sub new_frey_class {
214          my ( $self, $class, $params ) = @_;          my ( $self, $class, $params ) = @_;
215          my $instance = $class->new( %$params );          my $instance;
216            
217            if ( $class->meta->isa('Moose::Meta::Role') ) {
218                    $instance = Frey->new;
219                    Frey::Web->meta->apply( $instance );
220                    warn "new_frey_class $class role with Frey::Web";
221            } else {
222                    $params->{request_url} = $self->request_url;
223                    $instance = $class->new( %$params ) or confess "can't $class->new".dump( %$params );
224                    warn "new_frey_class $class";
225            }
226    
227          if ( $instance->can('data') && ! $instance->can('as_data') ) {          if ( $instance->can('data') && ! $instance->can('as_data') ) {
228                  Frey::Role::as_data->meta->apply( $instance );                  Frey::Role::as_data->meta->apply( $instance );
229                  warn "# apply as_data role to $class";                  warn "# apply as_data role to $class";
# Line 216  sub new_frey_class { Line 232  sub new_frey_class {
232                  Frey::Role::as_sponge->meta->apply( $instance );                  Frey::Role::as_sponge->meta->apply( $instance );
233                  warn "# apply as_sponge role to $class";                  warn "# apply as_sponge role to $class";
234          }          }
235    
236            if ( ! $instance->can('add_status') ) {
237                    Frey::Web->meta->apply( $instance );
238                    warn "# apply Frey::Web role to $class";
239            }
240    
241            $self->add_status({ $class => $params });
242          return $instance;          return $instance;
243  }  }
244    

Legend:
Removed from v.457  
changed lines
  Added in v.653

  ViewVC Help
Powered by ViewVC 1.1.26