comparison lib/IMPL/Config/Container.pm @ 417:3ed0c58e9da3 ref20150831

working on di container, tests
author cin
date Mon, 02 Nov 2015 01:56:53 +0300
parents 3d24b10dd0d5
children 3f38dabaf5cc
comparison
equal deleted inserted replaced
416:cc2cf8c0edc2 417:3ed0c58e9da3
45 $this->services( Bag->new() ); 45 $this->services( Bag->new() );
46 $this->root($this); 46 $this->root($this);
47 } 47 }
48 } 48 }
49 49
50 sub Require {
51 my ($this, $class) = @_;
52
53 return $this->loader->Require($class);
54 }
55
50 sub Register { 56 sub Register {
51 my ( $this, $role, $service ) = @_; 57 my ( $this, $role, $service ) = @_;
52 58
53 die IMPL::InvalidArgumentException->new('service') 59 die IMPL::InvalidArgumentException->new('service')
54 unless is( $service, Descriptor ); 60 unless is( $service, Descriptor );
62 role => 'The argument is required' ) 68 role => 'The argument is required' )
63 unless $role; 69 unless $role;
64 70
65 if ( isarray($role) ) { 71 if ( isarray($role) ) {
66 my $tempRole = "unnamed-" . $nextRoleId++; 72 my $tempRole = "unnamed-" . $nextRoleId++;
67 $this->role->AddRole( $tempRole, $role ); 73 $this->roles->AddRole( $tempRole, $role );
68 $role = $tempRole; 74 $role = $tempRole;
69 } 75 }
70 76
71 $this->roles->GetLinearRoleHash($role); 77 $this->roles->GetLinearRoleHash($role);
72 } 78 }
75 my ( $this, $role, %opts ) = @_; 81 my ( $this, $role, %opts ) = @_;
76 82
77 my $descriptor = $this->services->Resolve($role); 83 my $descriptor = $this->services->Resolve($role);
78 84
79 return $descriptor->Activate( ActivationContext->new($this) ) 85 return $descriptor->Activate( ActivationContext->new($this) )
80 if $descirptor; 86 if $descriptor;
81 87
82 return $opts{default} if exists $opts{default}; 88 return $opts{default} if exists $opts{default};
83 } 89 }
84 90
85 sub ResolveAll { 91 sub ResolveAll {