Changeset 25176
- Timestamp:
- 11/28/08 10:23:41 (4 years ago)
- Location:
- lang/perl/Shika/trunk
- Files:
-
- 1 added
- 2 modified
-
lib/Shika.pm (modified) (3 diffs)
-
lib/Shika/Role.pm (modified) (1 diff)
-
t/020_role/04_has_injection.t (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Shika/trunk/lib/Shika.pm
r25175 r25176 95 95 } 96 96 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 100 sub _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' : ''; 102 107 my $meth = "_has_install_${f1}${f2}"; 103 __PACKAGE__->can($meth)->( $pkg, $n );108 __PACKAGE__->can($meth)->( $pkg, $name ); 104 109 } 105 110 … … 208 213 } 209 214 210 if (@_==2) {215 if (@_==2) { 211 216 return $_[0]->{$n} = $has->{coerce}->($_[1]); 212 217 } … … 236 241 no strict 'refs'; 237 242 *{"$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); 238 248 } 239 249 } -
lang/perl/Shika/trunk/lib/Shika/Role.pm
r25072 r25176 26 26 sub _has { 27 27 my $pkg = caller(0); 28 push @{ $pkg->meta->{has h} }, [ @_ ];28 push @{ $pkg->meta->{has} }, [ @_ ]; 29 29 } 30 30
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)