/[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 559 by dpavlin, Thu Nov 27 21:01:39 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 35  sub classes { Line 36  sub classes {
36                  $class =~ s{\.pm$}{};                  $class =~ s{\.pm$}{};
37                  $class =~ s{/}{::}g;                  $class =~ s{/}{::}g;
38                  if ( $class =~ m{Mojo} ) {                  if ( $class =~ m{Mojo} ) {
39                          warn "# skip Mojo class $class";                          $self->TODO( "Mojo support" );
40                          return;                          return;
41                  }                  }
42                  $class_path->{ $class } = $_;                  $class_path->{ $class } = $_;
# Line 167  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 211  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 221  sub new_frey_class { Line 233  sub new_frey_class {
233                  warn "# apply as_sponge role to $class";                  warn "# apply as_sponge role to $class";
234          }          }
235    
236          $self->add_status({ $class => $params }) if $self->can('add_status');          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.559  
changed lines
  Added in v.653

  ViewVC Help
Powered by ViewVC 1.1.26