Module: Docks::Containers

Defined in:
lib/docks/containers.rb,
lib/docks/containers/base_container.rb,
lib/docks/containers/demo_container.rb,
lib/docks/containers/class_container.rb,
lib/docks/containers/mixin_container.rb,
lib/docks/containers/state_container.rb,
lib/docks/containers/symbol_container.rb,
lib/docks/containers/factory_container.rb,
lib/docks/containers/pattern_container.rb,
lib/docks/containers/variant_container.rb,
lib/docks/containers/function_container.rb,
lib/docks/containers/variable_container.rb,
lib/docks/containers/component_container.rb,
lib/docks/containers/variation_container.rb,
lib/docks/containers/pattern_library_container.rb

Defined Under Namespace

Classes: Base, Component, Demo, Factory, Function, Klass, Mixin, Pattern, PatternLibrary, State, Symbol, Variable, Variant, Variation

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.container_for(type = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/docks/containers.rb', line 14

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