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