Sha256: 230cb6ba6d7d47df1aedca46f23e5ef8813a2c597e9ad58263e9fc2759bbf213

Contents?: true

Size: 645 Bytes

Versions: 3

Compression:

Stored size: 645 Bytes

Contents

module Docks
  module Containers
    TOP_LEVEL_SYMBOLS = [
      Types::Symbol::COMPONENT,
      Types::Symbol::CLASS,
      Types::Symbol::FACTORY,
      Types::Symbol::FUNCTION,
      Types::Symbol::MIXIN,
      Types::Symbol::VARIABLE
    ]

    @@container_associations = Hash.new

    def self.container_for(type = nil)
      if @@container_associations.empty?
        constants.each do |const|
          klass = const_get(const)
          @@container_associations[klass.type.to_sym] = klass if klass.respond_to?(:type)
        end
      end

      type.nil? ? Symbol : @@container_associations.fetch(type.to_sym, Symbol)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
docks_app-0.0.3 lib/docks/containers.rb
docks_app-0.0.2 lib/docks/containers.rb
docks_app-0.0.1 lib/docks/containers.rb