Changeset 25176

Show
Ignore:
Timestamp:
11/28/08 10:23:41 (4 years ago)
Author:
tokuhirom
Message:

Role をぶちこむときに has も処理してくれ

Location:
lang/perl/Shika/trunk
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Shika/trunk/lib/Shika.pm

    r25175 r25176  
    9595    } 
    9696     
    97     my $f1 =       $attr{lazy} ? 'lazy' 
    98                                : 
    99              $attr{lazy_build} ? 'lazy_build' 
    100                                : 'normal'; 
    101     my $f2 = $attr{coerce} ? '_coerce' : ''; 
     97    Shika::_has_install($pkg, $n, \%attr); 
     98} 
     99 
     100sub _has_install { 
     101    my ($pkg, $name, $attr) = @_; 
     102    my $f1 =       $attr->{lazy} ? 'lazy' 
     103                                 : 
     104             $attr->{lazy_build} ? 'lazy_build' 
     105                                 : 'normal'; 
     106    my $f2 = $attr->{coerce} ? '_coerce' : ''; 
    102107    my $meth = "_has_install_${f1}${f2}"; 
    103     __PACKAGE__->can($meth)->( $pkg, $n ); 
     108    __PACKAGE__->can($meth)->( $pkg, $name ); 
    104109} 
    105110 
     
    208213        } 
    209214 
    210         if (@_==2) {  
     215       if (@_==2) {  
    211216            return $_[0]->{$n} = $has->{coerce}->($_[1]); 
    212217        } 
     
    236241            no strict 'refs'; 
    237242            *{"$target\::$method"} = *{"$role\::$method"}; 
     243        } 
     244 
     245        for my $attr (@{ $role->meta->{has} }) { 
     246            my ($name, $attrbody) = @$attr; 
     247            Shika::_has_install($target, $name, $attrbody); 
    238248        } 
    239249    } 
  • lang/perl/Shika/trunk/lib/Shika/Role.pm

    r25072 r25176  
    2626sub _has { 
    2727    my $pkg = caller(0); 
    28     push @{ $pkg->meta->{hash} }, [ @_ ]; 
     28    push @{ $pkg->meta->{has} }, [ @_ ]; 
    2929} 
    3030