/[Frey]/trunk/lib/Frey/Class/Loader.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/Class/Loader.pm

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

revision 582 by dpavlin, Fri Nov 28 13:18:18 2008 UTC revision 686 by dpavlin, Tue Dec 2 18:57:11 2008 UTC
# Line 35  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} ) {                  if ( 0 && $class =~ m{Mojo} ) { # FIXME remove dead code
39                          $self->TODO( "Mojo support" );                          $self->TODO( "Mojo support" );
40                          return;                          return;
41                  }                  }
# Line 61  sub class_path { Line 61  sub class_path {
61                  my $path = $class;                  my $path = $class;
62                  $path =~ s{::}{/}g;                  $path =~ s{::}{/}g;
63                  $path .= '.pm';                  $path .= '.pm';
64                  $path = $INC{$path};                  if ( defined $INC{$path} ) {
65                  warn "# $class from INC $path";                          $path = $INC{$path};
66                  $class_path->{$class} = $path || confess "can't find path for $class";                          warn "# $class from INC $path";
67                            $class_path->{$class} = $path;
68                    } else {
69                            confess "can't find path for $class";
70                    }
71          }          }
72          return $class_path->{$class};          return $class_path->{$class};
73  }  }
# Line 210  It is used by L<Frey::Run> and L<Frey::P Line 214  It is used by L<Frey::Run> and L<Frey::P
214          }          }
215  }  }
216    
217    our $syntax_checked_last;
218    
219  sub new_frey_class {  sub new_frey_class {
220          my ( $self, $class, $params ) = @_;          my ( $self, $class, $params ) = @_;
221          my $instance = $class->new( %$params );          my $instance;
222    
223            my $path = $self->class_path( $class );
224            if ( $syntax_checked_last->{$class} != -C $path ) {
225                    my $syntax = `perl -Ilib -wc $path 2>&1`;
226                    warn "# syntax: $syntax";
227                    $syntax_checked_last->{$class} = -C $class;
228            }
229    
230            if ( $class->meta->isa('Moose::Meta::Role') ) {
231                    $instance = Frey->new;
232                    Frey::Web->meta->apply( $instance );
233                    warn "new_frey_class $class role with Frey::Web";
234            } else {
235                    if ( $self->can('request_url') ) {
236                            $params->{request_url} = $self->request_url;
237                    } else {
238                            warn "## $self doesn't have request_url";
239                    }
240                    $instance = $class->new( %$params ) or confess "can't $class->new".dump( %$params );
241                    warn "new_frey_class $class";
242            }
243    
244          if ( $instance->can('data') && ! $instance->can('as_data') ) {          if ( $instance->can('data') && ! $instance->can('as_data') ) {
245                  Frey::Role::as_data->meta->apply( $instance );                  Frey::Role::as_data->meta->apply( $instance );
246                  $self->TODO("apply as_data role to $class");                  warn "# apply as_data role to $class";
247          }          }
248          if ( $instance->can('sponge') && ! $instance->can('as_sponge') ) {          if ( $instance->can('sponge') && ! $instance->can('as_sponge') ) {
249                  Frey::Role::as_sponge->meta->apply( $instance );                  Frey::Role::as_sponge->meta->apply( $instance );
250                  $self->TODO("apply as_sponge role to $class");                  warn "# apply as_sponge role to $class";
251          }          }
252    
253          if ( ! $instance->can('add_status') ) {          if ( ! $instance->can('add_status') ) {
254                  Frey::Web->meta->apply( $instance );                  Frey::Web->meta->apply( $instance );
255                  $self->TODO("apply Frey::Web role to $class");                  warn "# apply Frey::Web role to $class";
256          }          }
257    
258          if ( $self->can('add_status') ) {          $self->add_status({ $class => $params });
                 $self->add_status({ $class => $params });  
         } else {  
                 warn "# class $self can't add_status";  
         }  
259          return $instance;          return $instance;
260  }  }
261    

Legend:
Removed from v.582  
changed lines
  Added in v.686

  ViewVC Help
Powered by ViewVC 1.1.26