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.2.13 lib/yao/plugins/registry.rb
yao-0.2.12 lib/yao/plugins/registry.rb
yao-0.2.11 lib/yao/plugins/registry.rb
yao-0.2.10 lib/yao/plugins/registry.rb
yao-0.2.9 lib/yao/plugins/registry.rb
yao-0.2.8 lib/yao/plugins/registry.rb
yao-0.2.7 lib/yao/plugins/registry.rb
yao-0.2.6 lib/yao/plugins/registry.rb
yao-0.2.5 lib/yao/plugins/registry.rb
yao-0.2.4 lib/yao/plugins/registry.rb
yao-0.2.2 lib/yao/plugins/registry.rb
yao-0.2.1 lib/yao/plugins/registry.rb
yao-0.2.0 lib/yao/plugins/registry.rb
yao-0.2.0.rc1 lib/yao/plugins/registry.rb