Sha256: 5f204cbd13baff809be6b489906b315d7d580b45626808a5e1fc4595640ded8d

Contents?: true

Size: 448 Bytes

Versions: 34

Compression:

Stored size: 448 Bytes

Contents

require 'singleton'

module Yao::Plugins
  class Registry
    include Singleton

    def initialize
      @types = {}
    end

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

    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
  end

  def self.register(*a)
    Registry.instance.register(*a)
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
yao-0.8.0 lib/yao/plugins/registry.rb
yao-0.7.0 lib/yao/plugins/registry.rb
yao-0.6.3 lib/yao/plugins/registry.rb
yao-0.6.2 lib/yao/plugins/registry.rb
yao-0.6.1 lib/yao/plugins/registry.rb
yao-0.6.0 lib/yao/plugins/registry.rb
yao-0.5.0 lib/yao/plugins/registry.rb
yao-0.4.3 lib/yao/plugins/registry.rb
yao-0.4.2 lib/yao/plugins/registry.rb
yao-0.4.1 lib/yao/plugins/registry.rb
yao-0.4.0 lib/yao/plugins/registry.rb
yao-0.3.8 lib/yao/plugins/registry.rb
yao-0.3.7 lib/yao/plugins/registry.rb
yao-0.3.6 lib/yao/plugins/registry.rb
yao-0.3.5 lib/yao/plugins/registry.rb
yao-0.3.4 lib/yao/plugins/registry.rb
yao-0.3.3 lib/yao/plugins/registry.rb
yao-0.3.2 lib/yao/plugins/registry.rb
yao-0.3.1 lib/yao/plugins/registry.rb
yao-0.3.0 lib/yao/plugins/registry.rb