Class: Yao::Plugins::Registry

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/yao/plugins/registry.rb

Instance Method Summary collapse

Constructor Details

#initializeRegistry

Returns a new instance of Registry.



7
8
9
# File 'lib/yao/plugins/registry.rb', line 7

def initialize
  @types = {}
end

Instance Method Details

#[](type) ⇒ Object



11
12
13
# File 'lib/yao/plugins/registry.rb', line 11

def [](type)
  @types[type]
end

#register(klass, type: nil, name: :default) ⇒ Object



15
16
17
18
19
# File 'lib/yao/plugins/registry.rb', line 15

def register(klass, type: nil, name: :default)
  raise("Plugin registration requires both type and name.") if !type or !name
  @types[type] ||= {}
  @types[type][name] = klass
end