- Timestamp:
- 11/27/08 14:47:10 (4 years ago)
- Location:
- lang/perl/Shika/trunk
- Files:
-
- 1 added
- 1 modified
-
lib/Shika.pm (modified) (3 diffs)
-
t/010_core/08_lazy_build.t (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Shika/trunk/lib/Shika.pm
r25088 r25089 35 35 next unless exists $has->{default} && $has->{default}; 36 36 next if exists $has->{lazy} && $has->{lazy}; 37 next if exists $has->{lazy_build} && $has->{lazy_build}; 37 38 my $code = $has->{default}; 38 39 $attr{$name} = ref($code) eq 'CODE' ? $code->() : $code; … … 65 66 if (exists $attr{lazy} && $attr{lazy}) { 66 67 _has_lazy_install($pkg, $n, %attr); 68 } elsif (exists $attr{lazy_build} && $attr{lazy_build}) { 69 _has_lazy_build_install($pkg, $n, %attr); 67 70 } else { 68 71 _has_install($pkg, $n, %attr); … … 97 100 } 98 101 102 sub _has_lazy_build_install { 103 my($pkg, $n) = @_; 104 no strict 'refs'; 105 *{"$pkg\::$n"} = sub { 106 if (@_ == 1) { 107 unless (exists $_[0]->{$n}) { 108 die "$pkg does not support builder method '_build_$n' for attribute '$n'" 109 unless my $code = $pkg->can("_build_$n"); 110 return $_[0]->{$n} = $code->(); 111 } 112 return $_[0]->{$n}; 113 } 114 return $_[0]->{$n} = $_[1] if @_ == 2; 115 shift->{$n} = \@_; 116 }; 117 } 118 99 119 sub _extends { 100 120 my $pkg = caller(0);
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)