This repository has been archived by the owner on Apr 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kevin
committed
Sep 13, 2013
1 parent
0ff0e82
commit b22c265
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'dependency_injection/container' | ||
require 'dependency_injection/loaders/yaml' | ||
|
||
c = DependencyInjection::Container.new | ||
loader = DependencyInjection::Loaders::Yaml.new(c) | ||
loader.load(File.join(File.dirname(File.expand_path(__FILE__)), 'scoped_services.yml')) | ||
|
||
class ContainerScopedService | ||
def initialize | ||
puts 'Container scoped initialization' | ||
end | ||
end | ||
|
||
class PrototypeScopedService | ||
def initialize | ||
puts 'Prorotype scoped initialization' | ||
end | ||
end | ||
|
||
c.get('my.container.scoped.service') | ||
# => Container scoped initialization | ||
c.get('my.container.scoped.service') | ||
# => | ||
|
||
c.get('my.prototype.scoped.service') | ||
# => Prorotype scoped initialization | ||
c.get('my.prototype.scoped.service') | ||
# => Prorotype scoped initialization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
services: | ||
my.container.scoped.service: | ||
class: 'ContainerScopedService' | ||
my.prototype.scoped.service: | ||
class: 'PrototypeScopedService' | ||
scope: 'prototype' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
class ScopeWideningInjectionError < Error | ||
class ScopeWideningInjectionError < Exception | ||
end |