Module: Injection
- Defined in:
- lib/injection.rb,
lib/injection/railtie.rb,
lib/injection/version.rb,
lib/injection/class_inject.rb,
lib/injection/observer_inject.rb
Overview
Accessing Objects in the Context
Provides access to the context loaded from config/objects.yml
which can be used to look up individual components.
config/objects.yml:
---
foo:
bar:
lib/foo.rb:
class Foo
...
end
Inject.context[:foo] #=> #<Foo:0x81eb0>
Defined Under Namespace
Modules: ClassInject, ObserverExtension Classes: Railtie
Constant Summary collapse
- VERSION =
"2.0.2"
- @@context =
{}
- @@extra_inputs =
{}
Class Method Summary collapse
-
.context ⇒ Object
Accessor for the context loaded from
config/objects.yml
. - .context_file=(path) ⇒ Object
- .extra_inputs=(hash) ⇒ Object
- .reset_context ⇒ Object
Class Method Details
.context ⇒ Object
Accessor for the context loaded from config/objects.yml
29 30 31 |
# File 'lib/injection.rb', line 29 def self.context @@context end |
.context_file=(path) ⇒ Object
33 34 35 |
# File 'lib/injection.rb', line 33 def self.context_file=(path) @@context_file = path end |
.extra_inputs=(hash) ⇒ Object
37 38 39 |
# File 'lib/injection.rb', line 37 def self.extra_inputs=(hash) @@extra_inputs = hash end |
.reset_context ⇒ Object
41 42 43 |
# File 'lib/injection.rb', line 41 def self.reset_context @@context = DIY::Context.from_file(@@context_file, @@extra_inputs) if File.exists?(@@context_file) end |