Class: Dockdev::Context::ContextManager
- Inherits:
-
Object
- Object
- Dockdev::Context::ContextManager
- Includes:
- Singleton
- Defined in:
- lib/dockdev/context.rb
Instance Method Summary collapse
- #get_context(path) ⇒ Object
-
#initialize ⇒ ContextManager
constructor
A new instance of ContextManager.
- #register(name, cls) ⇒ Object
- #registered_context ⇒ Object
- #registered_context_by_name(name, path) ⇒ Object
Constructor Details
#initialize ⇒ ContextManager
Returns a new instance of ContextManager.
9 10 11 |
# File 'lib/dockdev/context.rb', line 9 def initialize @ctx = {} end |
Instance Method Details
#get_context(path) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dockdev/context.rb', line 30 def get_context(path) ctx = {} @ctx.each do |k, v| vv = v.init_path(path) if vv.is_context? #ctx << vv ctx[k] = vv end end ctx end |
#register(name, cls) ⇒ Object
13 14 15 |
# File 'lib/dockdev/context.rb', line 13 def register(name, cls) @ctx[name] = cls end |
#registered_context ⇒ Object
17 18 19 |
# File 'lib/dockdev/context.rb', line 17 def registered_context @ctx.keys.freeze end |
#registered_context_by_name(name, path) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/dockdev/context.rb', line 21 def registered_context_by_name(name, path) ctx = @ctx[id] if not ctx.nil? ctx.init_path(path) end ctx end |