Changeset 25109 for lang

Show
Ignore:
Timestamp:
11/27/08 16:28:16 (5 years ago)
Author:
tokuhirom
Message:

support required option

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

Legend:

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

    r25108 r25109  
    33use strict; 
    44use warnings; 
     5use Carp; 
    56our $VERSION = '0.01'; 
    67eval "use mro; 1;" or eval "use MRO::Compat; 1;"; ## no critic 
     
    4546            $attr{$name} = $has->{coerce}->($attr{$name}); 
    4647        } 
     48        # process 'required' 
     49        while (my ($name, $has) = each %{ $klass->meta->{has} }) { 
     50            next unless $has->{required}; 
     51            next if     exists $attr{$name}; 
     52            Carp::croak "missing parameter $name for $class"; 
     53        } 
    4754    } 
    4855 
     
    299306    - isa? 
    300307    - make coerce as dsl 
    301     - required 
    302308 
    303309=head1 SEE ALSO