Sha256: 0b9b4beb36dea66e78a7f9d32c258e049f93ef2f4634bb897c0da99e10e6c1a6

Contents?: true

Size: 862 Bytes

Versions: 3

Compression:

Stored size: 862 Bytes

Contents

require 'singleton'

module Dockdev
  module Context
    class ContextManager
      include Singleton 

      def initialize
        @ctx = {}  
      end

      def register(name, cls)
        @ctx[name] = cls
      end

      def registered_context
        @ctx.keys.freeze
      end

      def registered_context_by_name(name, path)
        ctx = @ctx[id]
        if not ctx.nil?
          ctx.init_path(path) 
        end

        ctx
      end

      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

    end
  end
end

Dockdev.logger.debug File.join(File.dirname(__FILE__),"context","*.rb")
Dir.glob(File.join(File.dirname(__FILE__),"context","*.rb")).each do |f|
  require f
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dockdev-0.4.2 lib/dockdev/context.rb
dockdev-0.4.1 lib/dockdev/context.rb
dockdev-0.4.0 lib/dockdev/context.rb