Sha256: d581c3683c328d9c6935a065a65ea87a76d775d993ebb08ed885f028bce04c99

Contents?: true

Size: 848 Bytes

Versions: 15

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

module Waylon
  # Registry of Sense subclasses known to Waylon
  class SenseRegistry
    include Singleton

    attr_reader :senses

    # A convenience wrapper around the singleton instance #register method
    # @param (see #register)
    # @return (see #register)
    def self.register(name, class_name)
      instance.register(name, class_name)
    end

    # Add the provided Sense class to the registry under `name`
    # @param name [String] The name of the Sense in the registry
    # @param class_name [Class] The Sense subclass to add
    # @return [Class] The Sense subclass
    def register(name, class_name)
      @senses ||= {}
      @senses[name.to_s] = class_name
    end

    # Provides a Hash version of this registry
    # @return [Hash]
    def to_hash
      (@senses || {}).dup
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
waylon-core-0.3.0 lib/waylon/sense_registry.rb
waylon-core-0.2.6 lib/waylon/sense_registry.rb
waylon-core-0.2.5 lib/waylon/sense_registry.rb
waylon-core-0.2.4 lib/waylon/sense_registry.rb
waylon-core-0.2.3 lib/waylon/sense_registry.rb
waylon-core-0.2.2 lib/waylon/sense_registry.rb
waylon-core-0.2.1 lib/waylon/sense_registry.rb
waylon-core-0.2.0 lib/waylon/sense_registry.rb
waylon-core-0.1.9 lib/waylon/sense_registry.rb
waylon-core-0.1.8 lib/waylon/sense_registry.rb
waylon-core-0.1.6 lib/waylon/sense_registry.rb
waylon-core-0.1.5 lib/waylon/sense_registry.rb
waylon-core-0.1.4 lib/waylon/sense_registry.rb
waylon-core-0.1.3 lib/waylon/sense_registry.rb
waylon-core-0.1.2 lib/waylon/sense_registry.rb