/[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 382 by dpavlin, Mon Nov 17 19:21:06 2008 UTC revision 416 by dpavlin, Tue Nov 18 14:42:58 2008 UTC
# Line 57  sub class_path { Line 57  sub class_path {
57                  $path .= '.pm';                  $path .= '.pm';
58                  $path = $INC{$path};                  $path = $INC{$path};
59                  warn "# $class from INC $path";                  warn "# $class from INC $path";
60                  $class_path->{$class} = $path;                  $class_path->{$class} = $path || confess "can't find path for $class";
61          }          }
62          return $class_path->{$class};          return $class_path->{$class};
63  }  }
# Line 88  sub class_meta { Line 88  sub class_meta {
88    
89          if ( ! $class->can('meta') ) {          if ( ! $class->can('meta') ) {
90                  my $instance = Moose::Meta::Class->create_anon_class;                  my $instance = Moose::Meta::Class->create_anon_class;
91                  warn "class $class isn't Moose, faking anon class";                  warn "class $class isn't Moose, faking anon class" if $self->debug;
92                  return ( $instance, 0 );                  return ( $instance, 0 );
93          }          }
94    
95          my $meta;          my $meta = $class->meta;
96          my $is_role = 0;          my $is_role = 0;
         my $instance;  
97    
98          if($class->meta->isa('Moose::Meta::Role')){          if($class->meta->isa('Moose::Meta::Role')){
99                  $is_role = 1;                  $is_role = 1;
100                  $instance = Moose::Meta::Class->create_anon_class;                  my $instance = Moose::Meta::Class->create_anon_class;
101                    warn "# apply $class on $instance";
102                  $class->meta->apply( $instance );                  $class->meta->apply( $instance );
                 $meta = $class->meta;  
103                  die $@ if $@;                  die $@ if $@;
104          } else {                  $meta = $instance->meta;
                 $meta = $class->meta;  
105          }          }
106          return ( $meta, $is_role );          return ( $meta, $is_role );
107  }  }
# Line 124  sub load_all_classes { Line 122  sub load_all_classes {
122          $loaded_class;          $loaded_class;
123  }  }
124    
125    =head2 class_methods
126    
127      my @all_methods = $o->class_methods( $class );
128    
129      my $class_method = $o->class_methods( $class );
130      if ( $class_method->{ $method } ) {
131            # $class has $method
132      }
133    
134    =cut
135    
136    sub class_methods {
137            my ( $self, $class ) = @_;
138    
139            confess "need class" unless $class;
140            if ( ! $class->can('meta') ) {
141                    warn "$class doesn't have meta (isn't Moose class)" if $self->debug;
142                    return;
143            }
144            my $meta = $class->meta;
145    
146            my $attr;
147            my $methods;
148            $attr->{$_}++ foreach $meta->get_attribute_list;
149            my @methods = map { $methods->{$_}++; $_ } grep { ! defined($attr->{$_}) && $_ ne 'meta' } $meta->get_method_list;
150            warn "# methods = ",dump( @methods ) if $self->debug;
151    
152            return @methods if wantarray;
153            return $methods;
154    }
155    
156  1;  1;

Legend:
Removed from v.382  
changed lines
  Added in v.416

  ViewVC Help
Powered by ViewVC 1.1.26